简体   繁体   中英

Auto Increment in SQL server 2005

How to add auto incrementing property to primary key of a table in Sql Server 2005 ? I have ProductID as primary key. I want to increment its value by 1 everytime a record is added. I didn't use IDENTITY keyword while creating table.

There is a lot posted about this either here in SO or in other places. What you are looking for is exactly this

how to set auto increment after creating a table without any data loss?

Thank you everyone . i have found another way of adding IDENTITY property without sql commands.

In SQL Server Management console , go to Object Explorer->Select your Database->Select your Table->Right click on the Column on which Identity property has to be specified->Choose Modify option. In column Poperties window , scroll to Identity Specification . Change value of IsIdentity to Yes and specify seed and increment values and save.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM