Tuesday, February 27, 2007

Magic EXEC SP_SDIDEBUG 'legacy_on'

In my previous job, I don't have to do too many stored procedures and those stored procedures are generally simple. The project I am working on right now involves a lot of stored procedures, and I need a good way to debug it. It's pretty easy if I am working in visual studio 2005 and SQL server 2005. Everything works right out of box.

But when I started to use visual studio 2003 to debug a stored procedure on SQL server 2005, it complained that the sp_sdidebug cannot be found. It's true, this particular debug procedure is not in the "Extended Stored Procedures" of the master database of the SQL server 2005, but it is in the master database of the SQL server 2000.

So, I moved the database to the SQL server 2000. It's getting much better, it can allow me to debug into the stored procedure from the server explorer.  It at least proved that the SQL debugger is working. But every time, when I tried to debug into the stored procedure from the vb.net code, it never stepped into the code.

I searched a lot of posts, and a lot of posts pointing to this KB328151. I tried this magic statement EXEC SP_SDIDEBUG 'legacy_on'  , no , it didn't work. I rebooted the server machine, tried this statement again, it seemed it worked finally. 

In the KB, it mentioned it's only an issue of SQL server sp3, actually, my SQL server is sp4 , and it still applys.

No comments: