Reputation: 987
I need to add an index to a table that already has the primary key indexed. The new index will be on another column.
I don't have enough permissions on this table to select 'Alter' by right clicking and selecting 'Script table as'.
Is there any way to add an index to a column without effecting any of the existing data?
myTable:
- id -- int -----> this is an identity column, set as PK and indexable
- bookid ---> varchar(20) ----> this is the column that needs index created
Upvotes: 22
Views: 33852
Reputation: 13959
You can execute create index script as below, which is similar to what Igor mentioned
CREATE NONCLUSTERED INDEX IX_YourTable ON dbo.YourTable (bookid)
Upvotes: 31