How to add auto-increment primary key in a existing table?

 Posted by vishalneeraj-24503 on 3/6/2014 | Category: Sql Server Interview questions | Views: 971 | Points: 40
Answer:

First assign Identity to a column then assign primary key to that column.

For Example:-
alter table project_master add project_id int identity;
Now,we can assign project_id column to primary key as below:-
alter table project_master add constraint pk_project_id_project_master primary key(project_id);


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response