In this post we will check how we can drop a Primary Key Constraint in sql server 2008.
Also you can check out my previous posts on:
- Show confirmation message in gridview for delete in Asp.net
- Upload multiple files in Asp.Net file upload control
- Add user to group in active directory using C#.Net
We can drop Primary Key Constraint by writing a query as well as we can drop by using Object Explorer.
By using Query:
Below is the query to remove or drop a primary key:
ALTER TABLE Employees
DROP CONSTRAINT PK_Employees_ID
GO
Here PK_Employees_ID is the Constraint name.
By Using Object Explorer:
Right click on the table -> Click on Design
or
Right click on the Primary Key column and then click on Modify.
The above step will open the table in Table Designer mode.
Now Right-click the row with the primary key and choose Remove Primary Key as shown in the fig below:
Here ID was the primary key column.
Also you can check out my previous posts on:
- Show confirmation message in gridview for delete in Asp.net
- Upload multiple files in Asp.Net file upload control
- Add user to group in active directory using C#.Net
We can drop Primary Key Constraint by writing a query as well as we can drop by using Object Explorer.
By using Query:
Below is the query to remove or drop a primary key:
ALTER TABLE Employees
DROP CONSTRAINT PK_Employees_ID
GO
Here PK_Employees_ID is the Constraint name.
By Using Object Explorer:
Right click on the table -> Click on Design
or
Right click on the Primary Key column and then click on Modify.
The above step will open the table in Table Designer mode.
Now Right-click the row with the primary key and choose Remove Primary Key as shown in the fig below:
Here ID was the primary key column.