You must Sign In to post a response.
  • Category: SQL Server

    How to delete constraint in SQL SERVER ?

    How to delete constraint in SQL SERVER ?
  • #278522
    Hi,

    use the following command..

    ALTER TABLE employee
    DROP CONSTRAINT pk_employee

    H.P.
    tamil

  • #278525
    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

  • #286309
    alter table Products Drop constrain pk_emp

  • #301166
    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


This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.