Created
September 22, 2013 21:44
-
-
Save Cyberloki/6664170 to your computer and use it in GitHub Desktop.
Query SP_Who
Who is accessing particular database - shows loginname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @coffee TABLE ( | |
spid int | |
, ecid int | |
, [status] varchar(50) | |
, loginame varchar(255) | |
, hostname varchar(255) | |
, blk varchar(50) | |
, dbname varchar(255) | |
, cmd varchar(255) | |
, request_id int | |
) | |
INSERT INTO @coffee EXEC sp_who | |
SELECT * FROM @coffee where [dbname] = 'MyDB' order by loginame |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment