my code stock.com

Snippet options

Download: Download snippet as check_sysprocesses.sql.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

select 
	case rtrim(status) 
		when 'background' then '0bg' 
		when 'runnable' then '9run' 
		when 'sleeping' then '2sleep' 
		when 'suspended' then '8suspend' 
		else rtrim(status) end 
		as status,
	spid,
	kpid,
	blocked,
	open_tran,
	rtrim(upper(hostname)) as hostname,
	rtrim(cmd) as cmd,
	db_name(dbid) as dbname,
	cpu,
	physical_io,
	waittime,
	lastwaittype,
	rtrim(waitresource) as waitresource,
	rtrim(loginame) as loginame,
	rtrim(program_name) as prg,
	sql_handle,
	 'dbcc inputbuffer('+cast(spid as varchar)+')' as i
from 
	sysprocesses with(nolock)
where 
	(open_tran <> 0 or blocked <> 0) 
	or spid in (select distinct blocked from sysprocesses with(nolock) where blocked <> 0) 
	or rtrim(status) = 'runnable' or rtrim(cmd) not in ('AWAITING COMMAND')
order by 
	status desc, 
	cpu desc, 
	physical_io desc, 
	waittime desc

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.