SQL SERVER – T-SQL Script to Add Clustered Primary Key

Jr. DBA asked me three times in a day, how to create Clustered Primary Key. I gave him following sample example. That was the last time he asked “How to create Clustered Primary Key to table?”
USE [AdventureWorks] GO
ALTER TABLE [Sales].[Individual] ADD CONSTRAINT [PK_Individual_CustomerID] PRIMARY KEY CLUSTERED
(
[CustomerID] ASC
)

Reference : Pinal Dave (https://blog.sqlauthority.com)

SQL Constraint and Keys, SQL Scripts
Previous Post
SQL SERVER – UDF vs. Stored Procedures and Having vs. WHERE
Next Post
SQL SERVER – Pre-Code Review Tips – Tips For Enforcing Coding Standards

Related Posts

Leave a Reply