<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cursors on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/cursors/</link><description>Recent content in Cursors on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Tue, 03 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/cursors/index.xml" rel="self" type="application/rss+xml"/><item><title>Inventory Open Cursors per Session with sys.dm_exec_cursors</title><link>https://www.sqlserver70.com/post/inventory-open-cursors-per-session-with-sys-dm-exec-cursors/</link><pubDate>Tue, 03 Nov 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/inventory-open-cursors-per-session-with-sys-dm-exec-cursors/</guid><description>
&lt;p&gt;If code declares a GLOBAL cursor and never deallocates it, the cursor &lt;a href="https://learn.microsoft.com/en-us/sql/t-sql/language-elements/declare-cursor-transact-sql?view=sql-server-ver17"&gt;stays allocated until the connection closes&lt;/a&gt;. While it stays open it can hold tempdb space, row locks or both. The collector query below snapshots every cursor on the instance with its properties, state, I/O and idle time, and a short follow-up query narrows the list to cursors more than 36 hours old with the session ID and login that own them.&lt;/p&gt;</description></item></channel></rss>