• pgmoschetti (5/6/2014)


    You are right, that's a good solution. I've only an additional problem, I must think of: as you said, it is a bulk delete. This bulk delete will be run by a .NET client where the customer has a list of all tables in the database, can select any of them, select a couple of dates and then issue that bulk delete on all the selected tables. Each table has its own trigger and on each table I shall disable that "AFTER DELETE".

    I will think on it, taking your suggestion as my starting point,

    Thanks, regards

    If this is something is going to happen frequently I would consider splitting your triggers into two. One for Insert, Update and the other for Delete. Then you can just modify your .NET code to first disable the delete trigger, fire your deletes, enable the delete trigger again. I am not a huge fan of triggers in general but if I do use them I like to keep the logic separate for the different types of actions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/