How do I use cascade delete with SQL Server?

  • I have 2 tables: T1 and T2, they are existing tables with data. We have a one to many relationship between T1 and T2. How do I alter the table definitions to perform cascading delete in SQL Server when a record from T1 is deleted, all associated records in T2 also deleted Prepaid Gift Balance

    The foreign constraint is in place between them. I don't want to drop the tables or create a trigger to do the deletion for T2. For example, when I delete an employee, all the review record should be gone, too.

    T1 - Employee,

    Employee ID

    Name

    Status

    T2 - Performance Reviews,

    Employee ID - 2009 Review

    Employee ID - 2010 Review

    • This topic was modified 4 years, 7 months ago by  Anthonys23.
  • You need either to manually delete the referencing rows after the referenced rows, or recreate the foreign key constraint with the ON DELETE CASCADE option.

    John

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

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