Auto increment primary key in SQL Server Management Studio 2012
Auto increment primary key in SQL Server Management Studio 2012
Auto increment primary key in SQL Server Management Studio 2012
Re: Auto increment primary key in SQL Server Management Studio 2012
Make sure that the Key column's datatype is `int` and then setting identity manually, as image shows
Or **just run this code** utilizing [IDENTITY(seed, increment)](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property?view=sql-server-ver16) modifier
```
-- ID is the name of the [to be] identity column
ALTER TABLE [yourTable] DROP COLUMN ID
ALTER TABLE [yourTable] ADD ID INT IDENTITY(1,1)
```
the code will run, if `ID` is not the only column in the table
*image reference fifo's*
Or **just run this code** utilizing [IDENTITY(seed, increment)](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property?view=sql-server-ver16) modifier
```
-- ID is the name of the [to be] identity column
ALTER TABLE [yourTable] DROP COLUMN ID
ALTER TABLE [yourTable] ADD ID INT IDENTITY(1,1)
```
the code will run, if `ID` is not the only column in the table
*image reference fifo's*