You must Sign In to post a response.

How to delete constraint in SQL SERVER ?

How to delete constraint in SQL SERVER ?


Comments

Author: Tamilarasan08 Aug 2008 Member Level: Silver   Points : 2

Hi,

use the following command..

ALTER TABLE employee
DROP CONSTRAINT pk_employee

H.P.
tamil


Author: Koteswara Rao08 Aug 2008 Member Level: Gold   Points : 5

CREATE TABLE employee(
EmployeeId INT NOT NULL,
LName VARCHAR(30) NOT NULL,
FName VARCHAR(30) NOT NULL,
Address VARCHAR(100) NOT NULL,
HireDate DATETIME NOT NULL,
Salary MONEY NOT NULL CONSTRAINT check_sale CHECK (salary > 0)
)
====================alter constr=========================
ALTER TABLE employee
ADD CONSTRAINT pk_employee PRIMARY KEY (EmployeeId)
====================delete constr=========================
ALTER TABLE employee
DROP CONSTRAINT pk_employee

Author: Sriram25 Aug 2008 Member Level: Gold   Points : 0

alter table Products Drop constrain pk_emp

Author: Ravi Kiran Nedunuri27 Sep 2008 Member Level: Gold   Points : 5

hi you can use the alter command for changing the structure of the table

ex:
create table bank2(cusid int constraint cusid_pk primary key,name varchar(10))

you have created a primary key like this on customer id in bank table

now for droping the constrint use the following command
ALTER TABLE BANK2 DROP CONSTRAINT cusid_pk

or you can use the sqlserver 2005 management studio like this
right on the desired table you can find the edit option click on edit
table appears
in that primary key column appers right click on it and select remove primary key


Regards
N.RaviKiran