The DBA Blog by Tomer Lev

SQL information, scripts, tricks and more…

Useful bit of code


create table #temp (spid int, status nvarchar(max), login nvarchar(max), hostname nvarchar(max), blkby nvarchar(max), dbname nvarchar(max), command nvarchar(max), cputime int, diskio int, lastbatch nvarchar(max), programname nvarchar(max), spid2 int, requestid int)

insert #temp exec sp_who2

select hostname, count(*)
from #temp
where hostname != ‘ .’ AND login = ‘your login’
group by hostname
order by hostname

drop table #temp

This way you can filter sp_who2.

enjoy 🙂

Advertisements

June 26, 2009 - Posted by | Scripts, SQL SERVER |

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: