Please help me delete a row in a table

  • Hi All,

    I hope you all have a great day.

    I have a difficulty of deleting a row from a table. Please Help!!!!!

    ***********???????????????????????????????

    delete from Customer where CustomerId ='8'

    Server: Msg 547, Level 16, State 1, Line 1

    DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_ Department_Customer'. The conflict occurred in database 'TEST', table 'Department', column 'CustomerId'.

    The statement has been terminated.

  • The error you are getting just means that a key on the table from where you are trying to delete "customer" has already been used in a row on the "Departments" table. At this point either you delete all the rows on the departments table where customerid = 8 or you won't be able to do it  without removing DRI.

     

    HTH

     


    * Noel

  • Or, you can add a cascading delete option for the primary table Customer and Departments, but only do this if you want this type of action.  Otherwise, the DRI helps prevent inadvertent deletes on the customer table when it is being used as a foreign key on another table.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply