Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 stored procedure sometimes hangs

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-08-09 : 03:44:21
We are using sql server 2005.
I have been asked to investigate why a job that runs a particular stored procedure (SP) SOMETIMES hangs.

What are the first steps to investigate this issue?
Is this just a matter of going through the sql inside the SP and look for possible casue of locks among tables?...

Any thoughts please?

Thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2007-08-09 : 04:49:14
First run this
http://www.nigelrivett.net/SQLAdmin/sp_nrInfo.html
That may show the problem - if it is blocked by something it should be highlighted
running
DECLARE @sql_handle binary(20)
SELECT @sql_handle = sql_handle
FROM master.dbo.sysprocesses
WHERE spid = @spid
AND ecid = 0
SELECT *
FROM ::fn_get_sql(@sql_handle)
might show the statement causing problems

Have a look at this
http://www.nigelrivett.net/SQLAdmin/SaveQueryPlans.html
It might show something.

Running the profiler will show which statements are executed and show where it is stuck but will slow the system down a bit.

This shows which locks are held - not sure if it works for v2005
http://www.nigelrivett.net/SQLAdmin/sp_nrLocks.html



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -