Go into Enterprise Manager.
Go into design mode and change the table how you want.
Click the "save change script" button (a yellow scroll paper thingie with a disk in front of it).
Voilá, you have an alter script. (Look in the resulting script for the ALTER section.)
All objects can be scripted in this way... now you never have to ask for syntax help again, just create the object and script it.
You cannot accomplish this using a T-SQL script. What you will have to do is what Enterprise Manager does when you add an Identity to a pre-existing field. Lets say our table is called TableA and FieldA needs to be set as an Identity field. We have data in table A so here is what we have to do ...
First rename TableA to say TableB
Create a new TableA WITH FieldA set as an Identity field.
Import data from TableB into TableA
DELETE TableB ... Once you are sure the new TableA meets your needs.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.