I have an stored proc running on sql server that hangs now and then. I havn't been able to find any common thread to give me a clue of why it hangs. The data could be the exact same and it will work one time and not another. There don't seem to be any deadlocks either.
The gist of the stored proc goes like this...
begin transaction
delete some records from table 1
select insert some records from table 2 to table 1 (replacing deleted old data with new data)
delete records from table 2
Commit
both table 1 and table 2 have a self referencing FK. I suspect this has something to do with it, but have no way to prove it.
So what I'm asking, are there some good techniques for debugging hanging stored procs when the problem seems intermittent?
The gist of the stored proc goes like this...
begin transaction
delete some records from table 1
select insert some records from table 2 to table 1 (replacing deleted old data with new data)
delete records from table 2
Commit
both table 1 and table 2 have a self referencing FK. I suspect this has something to do with it, but have no way to prove it.
So what I'm asking, are there some good techniques for debugging hanging stored procs when the problem seems intermittent?