Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Last_Batch timestamp - From "How to detect SqlServer connection leaks in a ASP.net applications?"
--Get-SPIDs_last_batch.sql
-- https://stackoverflow.com/questions/212596/how-to-detect-sqlserver-connection-leaks-in-a-asp-net-applications/12428235#12428235
SELECT S.spid, S.login_time, S.last_batch, S.status, S.hostname, S.program_name, S.cmd, S.loginame,
last_sql = ( select text from sys.dm_exec_sql_text(S.sql_handle) )
, database_name = DB_NAME(dbid)
FROM sys.sysprocesses S
INNER JOIN sys.dm_exec_sessions sx
on sx.session_id = S.spid
and sx.is_user_process = 1
where dbid > 4
--and s.program_name = '.Net SqlClient Data Provider'
--and s.program_name <> '.Net SqlClient Data Provider'
--and DB_NAME(dbid) = 'precious'
--and DB_NAME(dbid) = 'your_company_abbrev_Customers'
--and loginame IN ('login_1','login_3')
order by last_batch asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.