Script to track row changes of multiple tables

  • Hello,

    I have multiple tables in my stored procedure, first I need to track if there is any row changes in these tables, then 2nd I would need to set up the subscription to send the RDL to intended recipients when these changes take place.

    Can you please give me an idea how to handle these 2 things? Thanks so much in advance!

    Lily

  • Maybe something like this:

    Create and preset a variable at the beginning of the code...

    DECLARE @TableChanged TINYINT;

    Then add something like the following after each Insert, Update, or Delete of the tables.

    SELECT @TableChanged = SIGN(@@ROWCOUNT+@TableChanged);

    At the end of the code, if @TableChanged > 0, then do the RDL subscription thing. I'd help with that but I never use SSRS and don't have a clue how to do that part. I normally just create some HTML on-the-fly using FOR XML PATH to populate the body of an email and send the email.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • appolies not to visit this forum for a while, forgot password on this site, then I got busy with other projects. Thanks for your reply Jeff! I tried and it did not work for me, I think I need to create a trigger on each of the table everytime there's a row changed, then I need to create a SSIS package to do this task...I'm still thinking of ways how to achieve this. Thanks!

    Lily

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

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