I have a UNIQUE, NON CLUSTERED index on a table that is currently using 4 columns for the index.
I want to create an alter script that can merely add another column to this index. The new column type is varchar.
The database is SQL Server 2005.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot alter an index – all you can do is
drop the old index (
DROP INDEX (indexname) ON (tablename))re-create the new index with the additional column in it:
The
ALTER INDEXstatement in SQL Server (see docs) is available to alter certain properties (storage properties etc.) of an existing index, but it doesn’t allow changes to the columns that make up the index.