An inactive or sleeping session may still be a useful pooled connection. A customer case prompted my earlier session-cleanup script.
How to Kill Processes Idle for X Hours? – Interview Question of the Week #152
Interview question: how to kill processes idle for X hours in SQL Server? Here is a script that finds idle sessions and kills them.
SQL SERVER – What is the query used in sp_cursorfetch and FETCH API_CURSOR?
Activity Monitor shows FETCH API_CURSOR instead of the real query? I explain what sp_cursorfetch is and how to find the query running behind the cursor.
Cursor Options That Matter: LOCAL, FAST_FORWARD and STATIC
Test SQL Server cursor options, including LOCAL FAST_FORWARD and STATIC, on one loop while measuring time and tempdb cost.
Replacing a Running Total Cursor With a Window Function
That loop adding to a variable can usually become one window function. Here is the proof that the balances match, and the tie trap to watch for.
Ranking Functions Quiz: ROW_NUMBER, RANK or DENSE_RANK?
This Ranking Functions Quiz uses two tied scores to ask what number the next student gets from ROW_NUMBER, RANK and DENSE_RANK. The answer is 3, 3 and 2. A tested script proves it and replaces a cursor loop with one query.
Counting Users, Roles and Orphans in Every Database
Audit counting users across databases, include roles and schema ownership, and distinguish orphaned SQL users from contained identities.







