nested sql statments

  • Hello,

    I've a self join table when I delete or update it's id I want to delete or update all the direct and indirect affected records

    SQL server does not allow this type of cycle cascading I've decided to use triggers but this triggers will file recursively and they will be terminated at 34 level and I don't know the depth of records and event I disable the trigger and re enable it after completing the process how can I construct a SQL statement that achieve this logic?

  • Hi mashtal, truely speaking, i am unable to extract info from your post. I reaaly cant comprehend what you want from the code!! People here are unpaid volunteers who put up their time for arriving at a decent code. So i would suggest you pose

    1. CREATE TABLE Scripts for all the tables

    2. INSERT INTO TABLE SELECT scripts for the sample data

    3. CREATE scripts for extra indexes/constraints

    4. DESIRED Output - how u want your output to be - Clearly!

    Please post the above seeked and then you will receive wonderful , fully-tested, super-optimized code!

    Cheers!

  • I think you can use an INSTEAD OF trigger for the same. There you have to make sure that you delete/update the related data in proper order and then delete/update the actual data.


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

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

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