Adding primary key to an existing table.

Posted by Abhisek under Sql Server category on | Views : 1577
A primary key can also be added to ab existing table in the database if it has no other keys defined previously.

ALTER TABLE<table_name> ADD CONSTRAINT<cons_name>PRIMARY KEY<col_name>

This will add a primary key to the existing table.

Comments or Responses

Login to post response