Friday, July 18, 2008

SQL: You can't update a function while debugging it

article applies to: SQL debugging
keywords: SQL, debugging, VS2005, functions, stored procedures

I learned this the hard way yesterday while I was RDing (Remote Desktop) into my computer, debugging a SQL function from VS2005; I then, found a bug on the function and proceeded to update the function externally using Microsoft SQL Server Management Express (uff, that was tiring), however when I would execute the alter function it would take forever and never actually come back, I thought it was something with my RD session, so I logged in to the SQL server directly and tried there with same results, after a few minutes of waiting for SQL to commit my changes I realized I was debugging, and had stopped on a breakpoint on that function, I then exited out of VS debugging, tried again and voila it worked instantly.

So, yes, it was my bad, but I never got a timeout or any message indicating what the problem was, what if two developers are working on the same thing?
perhaps some work could be done to fix that, I can't imagine that being too hard, it DOES know that is locked, why not just give the user a message?

anyway, just sharing my experience with you, hoping it helps

1 comment:

Schmalls said...

This happened to me just now. I didn't realize I was still debugging it. I had to find your post to know what the problem was. Thanks.