Simple sql server monitoring

This query shows any process thats running more than 30 secs.

SELECT spid, cmd, status, loginame, open_tran, datediff(s, last_batch,
getdate ()) AS [WaitTime(s)]
FROM master..sysprocesses p
WHERE open_tran > 0
AND spid > 50
AND datediff (s, last_batch, getdate ()) > 30
ANd EXISTS (SELECT * FROM master..syslockinfo l
WHERE req_spid = p.spid AND rsc_type <> 2)

This query shows if a process is running more that 10 secs.

SELECT spid, waittime, lastwaittype, waitresource
FROM master..sysprocesses
WHERE waittime > 10000 -- The wait time is measured in milliseconds
AND spid > 50

you can kill the process with command - kill [spid]

Comments

Popular posts from this blog

SQL 2008

SQL Buddy

Microsoft a BI Force