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:

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