0

I have to debug a long running SQL Server stored procedure which dynamically builds and executes queries at runtime. I want to run a trace so I can see all of the individual pieces of SQL that are executed.

Which events will provide that level of detail?

I've been advised to use Stored Proc: RPC Completed; Batch Completed and Batch Started. But that's only bringing back the initial execution statement. ie. literally "exec MyStoredProcName".

Any ideas?

Thanks In Advance.

Jimbo
  • 1,685
  • 3
  • 12
  • 15
  • 1
    I don't have my laptop handy right now, but have you tried running the query management studio with the option to display actual execution plan enabled? – Justin Crabtree Jul 13 '13 at 08:39
  • 3
    try SP:StmtCompleted http://msdn.microsoft.com/en-us/library/ms189570.aspx – Ian Kenney Jul 13 '13 at 08:51
  • Both solutions revealed the SQL I was looking for, although the profiler approach is a lot cleaner as the results can easily be dumped to a table and interrogated and it doesn't generate a query plan for each statement. Thank you both for your responses. – Jimbo Jul 13 '13 at 12:30

0 Answers0