Add Primary Key Column To Existing Table Sql Server. ALTER TABLE A_UserTestTable ADD UserKey int identity11 not. To create a primary key.
However the primary key can only be created on columns that are defined as NOT NULL. GO INSERT INTO PrimaryKeyColumnAdd VALUES 1NULL 21 34 42. MySQL SQL Server Oracle MS Access.
Sometime the questions are very very simple but the answer is not easy to find.
Overview of SQL ADD COLUMN clause. In Object Explorer right-click the table to which you want to add a unique constraint and click Design. Two or more tables are related by means of Primary Key and Foreign Key relationships. Step one is to change Column2 to be NOT NULL.