Results 1 to 3 of 3

Thread: Cascading Delete and Updates in SQL Server 7.0

  1. #1
    Geenu Mathew Guest

    Cascading Delete and Updates in SQL Server 7.0


    Is it possible to perform a cascading delete and update using TRIGGERS on a table referenced by a foreign key constraint.?To be more specific.. if the primary key is deleted does the delete trigger on the primary table deletes the record in the foreign key table or does it return an error??
    if possible please send us the T SQL Statements .

    Thanks in Advance
    Geenu
    Ajaz Dawre

  2. #2
    Mike Guest

    Cascading Delete and Updates in SQL Server 7.0 (reply)

    Constraint violations are tested before triggers fire. If a constraint violation is detected, the statement is aborted and execution never gets to the trigger (and the trigger never fires). Therefore, you cannot use a declared FOREIGN KEY constraint to ensure that a relationship is never violated by the update of a foreign key and then also use a trigger to perform a cascading action (or other such action) when the primary key side of the same relationship is changed.

    Mike

    ------------
    Geenu Mathew at 7/15/99 4:59:50 AM


    Is it possible to perform a cascading delete and update using TRIGGERS on a table referenced by a foreign key constraint.?To be more specific.. if the primary key is deleted does the delete trigger on the primary table deletes the record in the foreign key table or does it return an error??
    if possible please send us the T SQL Statements .

    Thanks in Advance
    Geenu
    Ajaz Dawre

  3. #3
    Geenu Mathew Guest

    Cascading Delete and Updates in SQL Server 7.0 (reply)

    What is the best way to perform Cascading actions (Delete & Update) with foreign Key Constraints declared?


    ------------
    Mike at 7/16/99 4:18:37 PM

    Constraint violations are tested before triggers fire. If a constraint violation is detected, the statement is aborted and execution never gets to the trigger (and the trigger never fires). Therefore, you cannot use a declared FOREIGN KEY constraint to ensure that a relationship is never violated by the update of a foreign key and then also use a trigger to perform a cascading action (or other such action) when the primary key side of the same relationship is changed.

    Mike

    ------------
    Geenu Mathew at 7/15/99 4:59:50 AM


    Is it possible to perform a cascading delete and update using TRIGGERS on a table referenced by a foreign key constraint.?To be more specific.. if the primary key is deleted does the delete trigger on the primary table deletes the record in the foreign key table or does it return an error??
    if possible please send us the T SQL Statements .

    Thanks in Advance
    Geenu
    Ajaz Dawre

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •