Reputation: 223
I have several tables that were created and were not assigned primary Keys. The primary keys were also set to allow nulls. I would get an error when trying alter the potential primary key to not allow nulls:: Msg 5074, Level 16, State 1, Line 20.The index 'Missing_..' is dependent on column 'name'.
I learned that I would need to drop the index before altering the column, then add in the primary key and finally recreate the "missing" index.
However I need to know how to sript the index in order for me to recreate it.
Does anyone know how i can script it?
These are my current steps:
Missing the Create index:
CREATE INDEX [Missing_..] ON table name ([what goes here?], [what goes here?]) INCLUDE ([what goes here?], [what goes here?], [what goes here?])
Upvotes: 1
Views: 1207
Reputation: 7847
An easy way to see what the index looks like is in SSMS Object Explorer go to
Databases > YourDatabase > Tables > YourTable > Indexes
Find the index you want to see, right click
Script Index As > Create To > New Query Editor Window
This will show you the code to create the index.
Upvotes: 1