In this SQL Tutorial I will show you how to DROP PRIMARY KEY . For the purpose of this tutorial I will use SQL Server 2012.
Other Versions of SQL Server:
- SQL Server 2012
- This blog post has been written using SQL Server 2012
- SQL Server 2008 / R2
- The examples we used should work in SQL Server 2008 and R2
- SQL Server 2005
- We suspect that this will work in SQL Server 2005 as well
Who is it for?
- People who would like to learn basics of using DROP PRIMARY KEY statement.
- Those who are preparing for Microsoft certifications and need to cover this topic.
To drop a PRIMARY KEY constraint we can use following statement:
ALTER TABLE table name
DROP CONSTRAINT pk_constraint name
I go to Object Explorer, Tables, dbo.Client folder and in a dbo.Client I check the Primary Key name.
I use this Primary Key in my code below. Once my code I redy I run the query and I can see that was run successfully.
I go to Object Explorer dbo.Client and I can see that Keys folder is empty.
I hope that will help