Adding Identity to existing column with data in Sql Server -


this question has answer here:

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

Popular posts from this blog

java - unable show chart in xls document using jasper reports -

javascript - How to change image src on success AJAX -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -