Last active
December 18, 2015 04:39
-
-
Save marifrahman/5726800 to your computer and use it in GitHub Desktop.
Microsoft SQL Server Query to get the query being executed on a Database.
This file contains hidden or 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
select S.program_name,DB_Name(S.dbid),min(S.last_batch), t.text as 'last_sql',S.loginame,count(*) | |
from sys.sysprocesses S | |
CROSS APPLY sys.dm_exec_sql_text (S.sql_handle) t | |
where S.dbid > 3 | |
and DB_NAME (S.dbid) = 'MyDatabase' | |
group by S.program_name,S.dbid,t.text,S.loginame having count(*) > 6 | |
order by count(*) desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment