After Update Trigger

  • I have created an After Update trigger and wanted to know if there is a SQL table called UPDATED in 2012.

    For example I want use the query: SELECT * FROM UPDATED WHERE Active= 'Y'

    Or do I need to do a INSERTED DELETED JOIN instead?

    SELECT I.* FROM INSERTED I INNER JOIN DELETED D ON I.EID = D.EID AND WHERE Active= 'Y'

    Thank you in advance

  • Meatloaf (1/5/2016)


    I have created an After Update trigger and wanted to know if there is a SQL table called UPDATED in 2012.

    No, there is not.

    Or do I need to do a INSERTED DELETED JOIN instead?

    SELECT I.* FROM INSERTED I INNER JOIN DELETED D ON I.EID = D.EID AND WHERE Active= 'Y'

    Yes, but you will need to use I.Active to avoid errors.

    Also, if people are allowed to update the value of the join column (EID in your example), the required code gets even more "interesting".


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Thank you clarifying I appreciate it.

    My code sample I wrote quickly and I should have provided a better example.

    Thank again. 🙂

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

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