Getting row and column which trigger's fired

  • Hello Friends!

    I have a trouble to get specific row and column when updated, inserted or deleted trigger is fired. I don't want to rollback those transactions but I would like to know which row, which column is updated and store

    these data in another table for history. Please help me!

  • The row that got updated can be found from the INSERTED or DELETED table. Those tables have the same layout as your source table, so if you take the PK-fields from either of them (depending on the type of trigger/action), you get a pointer to the row(s) that got updated.

    For the columns, you could use the COLUMNS_UPDATED() function. This gives you a bitmask of which columns where updated. Check BOL for specific info.

    Don't know how this works if you have a recordset that got changed.

  • Piggy-backing on Noel I found this http://www.umachandar.com/technical/SQL70Scripts/Main36.htm to be useful when dealing with COLUMNS_UPDATED()

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Hi NPeeters and Frank,

    Thank you so much for your advices. I solved my problem.

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

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