Kill Leaking Connections on SQL Server 2005

Posted by Thierry Brunet on Server Fault See other posts from Server Fault or by Thierry Brunet
Published on 2010-05-06T17:05:35Z Indexed on 2010/05/06 17:08 UTC
Read the original article Hit count: 269

We have a legacy ASP application that somewhere leaks SQL Connections. In Activity Monitor, I can see a bunch of idle processes with Last Batch times over an hour old.

When I look at the T-SQL command batch, these are always FETCH API_CURSORXXX, which from my understanding is caused by improperly closed ASP ADO Recordsets.

While we are try to pinpoint the offeding code, is there a way for me to monitor which requests open which cursors? I'm assuming profiler, but I'm not sure what I should be monitoring exactly. I can see a bunch of calls to sp_cursoropen but I don't see the API_CUSORXXX name anywhere.

Second, would anyone be able to suggest a script we could run to kill these processes based on the Last Batch time > 10 minutes and Last Batch Command being FETCH API_CURSORXXX?

For various reasons, we unfortunately don't have any SQL Server DBAs.

© Server Fault or respective owner

Related posts about sql-server-2005

Related posts about kill