Monday, 18 April 2016

How to add Primary key in the existing table in SQL server ?

Primary key is a kind of constraint in SQL server .To add the primary key in the existing table , you can do it in two ways.
  1. Using SQL Management Studio
  2. Using T-SQL Query
Using SQL Management Studio:

Step1:
Expand the database ,right click the required table and click the design option as shown below.



Step2:

Right click the required column and select the option as set the primary key as shown below.




Step3:

After clicking the option you can find the Key icon in the selected column as shown below.


Primary key is created successfully in StudentDetail table using SQL Management studio.

Using T-SQL Query:

No comments:

Post a Comment