[SQL Server] How to kill old sleeping sessions
BLOG
7/1/20241 min lire
Sessions can sometimes remain open on SQL Server database instances for various reasons. The most common is poor connection management at the application or API level (such as no defined timeout).
You may therefore need to clean up and kill certain sleeping sessions, for example, to free up connections in the connection pool.
It should be noted that this action should not be automatic. Instead, it is important to identify and correct the root cause.
To kill sleeping sessions that have been open for 25 hours, use the following script :