Deleting child table record delete associated parent table record

Posted on 2004-11-18
Last Modified: 2008-02-20
Using SQL Server 2000.

I have one parent table and a child table. At one time there was a Cascade Delete relationship between the parent's primary key and the child's associated foreign key.

When a child table record was deleted, its associated parent table record was also deleted. This deletion was unwarranted. Hence, I have removed any relationship between the parent primary key and the child foreign key. Yet, when deleting another child table record, the parent table record is still being deleted.

Any suggestions?
Question by:mic138
    LVL 11

    Expert Comment

    Can you script these two tables with all the constraints and see still any relation exist....Just to double check you cleared the relations.

    LVL 17

    Expert Comment

    Are you sure you don't have that back to front?
    A normal cascade delete will delete the child when the parent record is deleted, not the other way round. If you do have a scenario whre the parent record is deleted whenever the child record is delted, then this will be enforced by a custom trigger, not by a cascade delete. Check if you have such a trigger on the child table.
    LVL 16

    Accepted Solution

    In Query Analyzer, open the object explorer (F8), expand the database down to the child table and then expand its triggers. Have a look there, you may find there is a trigger that is doing this delete. Right click, Script to new windows as drop, run the script, and it's gone.

    Author Comment

    Indeed! There was a trigger set to delete the corresponding parent table record when the child table record was deleted. I will edit the script in Enterprise Manager and remove the deletion (there is other code which I wish to retain). Thank you for your help.
    LVL 16

    Expert Comment

    You're welcome.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    The steps for moving the system databases to a new location are documented in the following technical article: However sometimes after the moving process is finished, though SQL i…
    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now