I have a query:

select LastReqTime, BlockedOn, UncommitOps from sa_conn_info()
where LastReqTime< DATEADD(mi,-45,GETDATE()) AND BlockedON > 0 AND UncommitOps=0
I want to add an additional filter so that it only queries entries in the LockTable column beginning with "DBA.D2_TASK" so DBA.D2_TASK% (if I'm using that wildcard correctly). I've tried a few different variations but evidently I'm not getting the correct sequence.

Once I have the data, I want to pass the BlockedOn value to a drop command (simply: drop connection #BlockedON). I've spent quite a few hours researching and either I'm doing something that's never been done, it's not possible, or I'm not using the right search terms, because I havent found much on processing the output from queries.

Any assistance would be greatly appreciated.