SQL Server > Table

Set Primary key in SQL Server

How to specify a primary key in the database table in SQL Server?

Open the database table in the Design view, select Design option by right clicking the table name from the database as shown below.

This opens up the table in design view. Now keep the mouse cursor on the column name which needs to be specified as primary key and click on Set Primary Key (key symbol) icon from the top-left as shown below.

Clicking the icon marks the column as Primary key (key symbol beside it).

Do not forgot to click on the Save icon to save the table otherwise the changes will not affect in the database table.

 Views: 2167 | Post Order: 15

Write for us