How to create an Autonumber field in SQL Server 2012

Same as it was in the last version.

The task can either be performed through the Server Management Studio designer to code

In the designer,

  • select the field
  • ensure it’s an int
  • Set the Column Properties as IsIdentity

 

Or through code

ALTER TABLE [tableName] DROP COLUMN ID 
ALTER TABLE [tableName] ADD ID INT IDENTITY(1,1)

David Gregory Medina

Post created by: David Gregory Medina

Tagged with: , , ,

Leave a Reply