How to get update source t-sql statement inside a trigger

  • How can i get the update T-SQL statement that causes update and provokes the trigger? I want to get the source T-SQL statement inside the trigger.

    Regards

    DBDigger Microsoft Data Platform Consultancy.

  • You can use something like this:

    DECLARE @SQLBuffer nvarchar(4000)

    DECLARE @buffer TABLE (

    EventType nvarchar(30),

    Parameters int,

    EventInfo nvarchar(4000)

    )

    INSERT @buffer

    EXEC sp_executesql N'DBCC INPUTBUFFER(@@spid) WITH NO_INFOMSGS'

    SELECT @SQLBuffer = EventInfo

    FROM @buffer

    Hope this helps

    Gianluca

    -- Gianluca Sartori

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

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