How to get sql queries when a trigger starts, up to n levels?

I want to list requests made to the level "AFTER TRIGGER UPDATE" to level n . Listing will be done in TRIGGER itself. n may be 4 or less.

Any pointer, or if listing can be done in any other way, would it be helpful?

I need to debug the interface and the interface if there is an error there.

- Edit -

In fact, the cell is updated every time as empty. I have to track him. This is very rare.

- Edit -

Or tell me how to get the last n requests made by the user.

- Edit-- I did the following:

SELECT top(15) dest.text AS [Query]
        FROM sys.dm_exec_query_stats AS deqs
        CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
          --inner join  sys.sysprocesses
          -- on sys.sysprocesses.sql_handle=deqs.sql_handle
        ORDER BY deqs.last_execution_time DESC

- , , , . , .

SQL- ( , ".. , n ?" )

+3
1

SQL Server 2008, , TSQL. . , , .

+1

Source: https://habr.com/ru/post/1768937/


All Articles