Adding Identity to existing column with data in Sql Server -
this question has answer here:
- adding identity existing column 19 answers
i have table 4 million records. want change orderid
identity
without losing data.
is possible?
assuming orderid have no duplicates, 1. can create new table orderid identity column , copy data. drop existing table 2. create new identity column , drop existing orderid column
alter table (yourtable) add newcolumn int identity(1,1) alter table (yourtable) drop column orderid sp_rename 'yourtable.newcolumn', 'orderid', 'column'
Comments
Post a Comment