4

I want to list down the queries executed before the 'AFTER UPDATE TRIGGER' triggered up to n levels. The listing will be done within the TRIGGER itself. The n can be 4 or less.

Any pointer or if listing can be done by any other way will be helpful?

I have to debug the front-end and back-end if bug is there.

--Edit--

Actually a cell is being update each time as empty. I have to track it down. It happens very rarely.

--Edit--

Or say how to get the last n queries executed by the user.

--Edit-- I did as follows:

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

The code after -- seems to be working where as the full code gives the all users code executed queries. I comented them because It is heavy for the server.

The connecting Question is here SQL cell wise trigger (Which is the flow comes before the issue posted as ' .. triggered, upto n levels?')

Community
  • 1
  • 1
Rick2047
  • 1,565
  • 7
  • 24
  • 35
  • you mistaged your question MySQL, I retagged it SQL-server. You seem to have solved the problem though, have you? – Johan May 22 '11 at 15:55
  • Ok i'll do that. This I've solved but m really out of context now. work pressure really makes you to move on fast. – Rick2047 May 24 '11 at 05:53

1 Answers1

2

If you are on SQL Server 2008 you can use extended events to get the whole TSQL call stack. See my answer here for example code.

Community
  • 1
  • 1
Martin Smith
  • 438,706
  • 87
  • 741
  • 845