Question

It is possible to alter existing MSSQL column to add auto increment option to this column (it is primary key, but not auto increment) without writing t-sql code, but just with alter stratements?

I can find solution with t-sql, but I need without it.

Was it helpful?

Solution

according to this link http://social.msdn.microsoft.com/Forums/sqlserver/en-US/04d69ee6-d4f5-4f8f-a115-d89f7bcbc032/how-to-alter-column-to-identity11 "You can't alter the existing columns for identity." It provides a couple of possible solutions. Relevant commands are:

alter table YourTable drop column OldId
alter table YourTable add NewId int identity(1,1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top