Created
November 26, 2015 10:44
-
-
Save regisbsb/ed428a3421b4dad87841 to your computer and use it in GitHub Desktop.
Shows the last command on connection
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
SELECT S.spid, login_time, last_batch, status, hostname, program_name, cmd, | |
( | |
select text from sys.dm_exec_sql_text(S.sql_handle) | |
) as last_sql | |
FROM sys.sysprocesses S | |
where dbid > 0 | |
and DB_NAME(dbid) = '<my_database_name>' | |
and loginame = '<my_application_login>' | |
order by last_batch asc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment