Changing a column to IDENTITY
-
Hi everybody. SQL Server 2005 I've got a table "Center (ID,Name)", it has some records registered. I need to change the ID field, and make it IDENTITY = true. I have been searching, and only found information about how to add a new identity column to an existing table, but I have to turn an existing field on a table to Identity. I cannot create a new identity field and then delete the old one, because the registered IDs are not sequential... Any ideas? Thanks a lot.
Time to come clean... Vive y deja vivir / Live and let live Javier
-
Hi everybody. SQL Server 2005 I've got a table "Center (ID,Name)", it has some records registered. I need to change the ID field, and make it IDENTITY = true. I have been searching, and only found information about how to add a new identity column to an existing table, but I have to turn an existing field on a table to Identity. I cannot create a new identity field and then delete the old one, because the registered IDs are not sequential... Any ideas? Thanks a lot.
Time to come clean... Vive y deja vivir / Live and let live Javier
Follow the steps 1)Go to the design view of your table 2)Select ID Column 3) In the down, you will find Column Properties 4)In that you will find Identity Specification whose first property is Identity Specification. The default will be set to "No". Change that to yes. 5)Save the table. Hope this helps :)
Niladri Biswas
-
Follow the steps 1)Go to the design view of your table 2)Select ID Column 3) In the down, you will find Column Properties 4)In that you will find Identity Specification whose first property is Identity Specification. The default will be set to "No". Change that to yes. 5)Save the table. Hope this helps :)
Niladri Biswas
Thanks Niladri, but I meant how to do it in SQL language...
-
Thanks Niladri, but I meant how to do it in SQL language...
Follow the steps 1)Go to the design view of your table 2)Select ID Column 3) In the down, you will find Column Properties 4)In that you will find Identity Specification whose first property is Identity Specification. The default will be set to "No". Change that to yes. 5)Click on "save change script" 6) Save the script to a file or copy it to the clipboard.
Wout Louwers
-
Thanks Niladri, but I meant how to do it in SQL language...
This may help a) http://stackoverflow.com/questions/1049210/adding-an-identity-to-an-existing-column-sql-server[^] b) http://www.mssqltips.com/tip.asp?tip=1397[^] :)
Niladri Biswas