Enable Primary Key

ALTER INDEX statement is used to enable a primary key in SQL Server database.

Syntax:

ALTER INDEX constraint_name ON table_name  

REBUILD;

Example:

Enable the primary key “customer_id” on the table “customers”.

ALTER INDEX cricketers2_pk ON .[dbo].[cricketers2]  

REBUILD;

Output:

SQL Enable primary 1

Now primary key “customer_id” is enabled in table “customers”.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *