I am using SQL Server 2008. One int column I used as primary key but not identity column (whose value will be increased by 1 automatically). I want to convert this column to identity column. Any solutions?
thanks in advance,
George
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, you cannot change a field to
IDENTITYon an existing table.You should:
IDENTITYfieldSET IDENTITY_INSERT ONfor the new tableSET IDENTITY_INSERT OFFfor the new tableYou can use
SSMSto change the field type, it will do all this for you behind the scenes.Here’s a sample table:
and the script generated by
SSMS: