Home > SQL Challenge > Find and kill my own long running session – sp_who and more

Find and kill my own long running session – sp_who and more

The well known system procedure sp_who will show me all the running sessions and the spid. To find out just my running sessions, use this query:

SELECT    p.spid
,        d.name as db_name
,        p.program_name
,        l.name as login_name
,        p.hostname
,        p.cmd
,        p.status
,        p.blocked
,        p.login_time
,        p.last_batch
FROM    master..sysprocesses p
JOIN    master..sysdatabases d ON p.dbid =  d.dbid
JOIN    master..syslogins l ON p.sid = l.sid
where    l.name = ‘domain\myLoginId’
order by
        p.last_batch

To kill my own long running session:

kill 77

Categories: SQL Challenge
  1. No comments yet.
  1. No trackbacks 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: