SQL Server add auto increment primary key to existing table
1
ALTER TABLE dbo.YourTable ADD ID INT IDENTITY
2
ALTER TABLE dbo.YourTable ADD CONSTRAINT PK_YourTable PRIMARY KEY(ID)
Or by one line
ALTER TABLE dbo.YourTable ADD ID INT IDENTITY CONSTRAINT PK_YourTable PRIMARY KEY CLUSTERED
See--
https://stackoverflow.com/questions/4862385/sql-server-add-auto-increment-primary-key-to-existing-table