I can see from sp_who2, dbcc opentran, dbcc inputbuffer, etc that our sql server has some sleeping connections that are holding open transactions (along with some X locks) for long periods of time. I'm not sure the DMVs\tables to use to get this info but I need a query that returns this info when run:
<Datetime>
SPID
HostName
ProgramName
DBName
output of dbcc inputbuffer(<spid>) -- the sleeping query last running
State ( for state = "sleeping")
trancount ( if > 0)
BlkBy
X-lock (if lock is of type "X")
<time X lock held or something similar>
I'm focusing on X locks assuming that sleeping transactions with "S" locks are OK. (Maybe that's a bad assumption, not sure).
I will store the output in a table to gather historical data about this issue.
TIA,
edm2