Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Question Unanswered: Delete multiple tables

    Hi everyone,

    I spent a lot of time on this, but still have no idea how to get it working

    This are the tables with forign keys that I have:

    Table1 has table_1_id, table_1_data columns
    Table2 has table_1_id, table_2_id, table_2_data columns
    Table3 has table_2_id, table_3_id, table_3_data columns
    Table4 has table_3_id, table_4_id, table_4_data columns

    If I delete a row in table1, any related rows in table2 should be deleted, and at the same time, any rows in table3 which are related to table2 and related to table1 should be deleted as well and so on....

    is there a way that I can write a SQL query to do it?

    I am using MS SQL 2000 and ASP.net C#

    Many thanks

    Eric

  2. #2
    Join Date
    Oct 2001
    Location
    Naples, FL
    Posts
    273
    Lookup "cascading referential integrity constraints" in BOL, you can use the on delete cascade function for your foreign keys

    HTH
    ---------------
    Ray Higdon MCSE, MCDBA, CCNA

  3. #3
    Join Date
    Sep 2003
    Posts
    2
    Originally posted by rhigdon
    Lookup "cascading referential integrity constraints" in BOL, you can use the on delete cascade function for your foreign keys

    HTH
    Thanks for the information, this gives me a good hint. But I don't know what "BOL" means, could you explain it to me?

    Thanks a lot

    Eric

  4. #4
    Join Date
    Oct 2001
    Location
    Naples, FL
    Posts
    273
    Sorry, BOL is Books-online. It comes installed with SQL and is the best resource a SQL developer has (in the grand scheme of things) If you do not have it installed, you should and if you have not downloaded the latest BOL from MS (SP3A) you should and can at this location.

    http://www.microsoft.com/downloads/d...displaylang=en

    GL
    ---------------
    Ray Higdon MCSE, MCDBA, CCNA

Posting Permissions

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