Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I attach to and debug a running SQL Server stored procedure?

I am investigating an odd error from a SQL Server 2005 stored procedure which I cannot reproduce by calling it directly from Management Studio.

Therefore I'd like to be able to:

  • set a breakpoint in the stored procedure
  • wait for the procedure to be called externally and the breakpoint hit
  • see the values of the passed-in parameters
  • step through the stored procedure

Is this possible, and if so how?

like image 774
Matthew Murdoch Avatar asked May 14 '09 15:05

Matthew Murdoch


People also ask

How do I debug SQL stored procedure in SQL Server Management Studio 19?

To debugging SP, go to database->Programmability->Stored Procedures-> right click the procedure you want to debug->select Debug Procedure.


2 Answers

You could try the "server explorer" from visual studio but the sqlserver needs to be configured to allow debugging. Here is some info: http://www.4guysfromrolla.com/articles/051607-1.aspx. But I think that you first should try Profiler like Eppz say. :)

like image 69
Lucas Avatar answered Jan 21 '23 22:01

Lucas


Use SQL Profiler to view what is happening when the procedure gets called and what params are passed in.

like image 36
Eppz Avatar answered Jan 21 '23 20:01

Eppz