Created
September 22, 2013 21:43
-
-
Save Cyberloki/6664157 to your computer and use it in GitHub Desktop.
Query SP_Who2
Who is accessing particular database programname and login
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 | |
, [status] varchar(50) | |
, [Login] varchar(255) | |
, HostName varchar(255) | |
, BlkBy varchar(50) | |
, [DBName] varchar(255) | |
, [Command] varchar(255) | |
, CPUTime int | |
, DiskIO int | |
, LastBatch varchar(255) -- DateTime | |
, ProgramName varchar(255) | |
, SPID_ int | |
, request_id int | |
) | |
INSERT INTO @coffee EXEC sp_who2 | |
SELECT * FROM @coffee where [dbname] = 'MyDB' and [ProgramName] = 'MyApp' order by [login] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment