Blog
Projects
About
Backtrack:
Blog
›
Show long running processes/qu…
Comments
Show long running processes/queries on SQL Server
posted on September 3rd 2015, at 11:05
by
lunarg
Run the following T-SQL statements.
Show a list of longest running SPIDs on a SQL Server:
select P.spid, right(convert(varchar, dateadd(ms, datediff(ms, P.last_batch, getdate()), '1900-01-01'), 121), 12) as 'batch_duration', P.program_name, P.hostname, P.loginamefrom master.dbo.sysprocesses Pwhere P.spid > 50and P.status not in ('background', 'sleeping')and P.cmd not in ('AWAITING COMMAND' ,'MIRROR HANDLER' ,'LAZY WRITER' ,'CHECKPOINT SLEEP' ,'RA MANAGER')order by batch_duration desc
To retrieve the SQL for a specific SPID:
declare @spid int, @stmt_start int, @s
...
read more
add a comment
On February 13th 2020 at 14:49,
Stephen Keogh
wrote:
Thank you for your posting
Why is stmt_start / 2 ?
add a comment
Tags
computer
software
windows
vmware
microsoft
linux
exchange
network
hardware
news
mac
home
powershell
office365
msoffice
server
sqlserver
ad
dell
soaring
internet
esx
rds
sbs
mssql
events
terminalserver
hp
virtualization
antivirus
Archive
«
‹
January 2021
›
»
Sun
Mon
Tue
Wed
Thu
Fri
Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Links
-
@harkx
-
Cats & Dogs
-
Jargon-free Security Guide
Quote
«
If the batteries of a TV remote run out, why do we press the buttons so much harder?
»
Contact
© 2009-2021 Black Manticore – all rights reserved
code by
lunarg
, design by
SuriAmanah
, hosted at Cats&Dogs