Wednesday, July 11, 2012

SQL SERVER – How to Drop Primary Key Constraint



Run this Script to do the thing-

--Select Database
USE [AdventureWorks]
GO
-- Creating New table
CREATE TABLE [dbo].[Test_Table](
      [int] [int] NOT NULL,
      [name] [varchar](50) NULL,
 CONSTRAINT [PK_Test_Table] PRIMARY KEY CLUSTERED (   [int] ASC))
ON [PRIMARY]
GO

Result:-

Command(s) completed successfully.


--Now Drop Primary Key Constraint
ALTER TABLE [dbo].[Test_Table]
DROP CONSTRAINT  [PK_Test_Table]
GO

Result:-

Command(s) completed successfully.

Like and Share to SQL Integrity Blog

No comments:

Post a Comment

Thank You !!!!