Click to Rate and Give Feedback
TechNet
TechNet Library
SQL Server
SQL Server 2008
Database Engine
Development
 Dynamic Cursors (Database Engine)

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
Other versions are also available for the following:
SQL Server 2008 Books Online (June 2009)
Dynamic Cursors (Database Engine)

Dynamic cursors are the opposite of static cursors. Dynamic cursors reflect all changes made to the rows in their result set when scrolling through the cursor. The data values, order, and membership of the rows in the result set can change on each fetch. All UPDATE, INSERT, and DELETE statements made by all users are visible through the cursor. Updates are visible immediately if they are made through the cursor using either an API function such as SQLSetPos or the Transact-SQL WHERE CURRENT OF clause. Updates made outside the cursor are not visible until they are committed, unless the cursor transaction isolation level is set to read uncommitted.

Dynamic cursor plans never use spatial indexes.

ms189099.note(en-us,SQL.100).gifNote:
If the execution plan chosen to execute a query for a dynamic cursor is using a heap scan, and conditions are such that a page or table lock is acquired, deleting a row may result in the whole page being deallocated. In this case, the markers used by dynamic cursors for positioning may become invalid and a subsequent fetch from the cursor may fail with error 16931. Possible solutions include creating a clustered index on the table, using a different cursor type, or evaluating whether it is possible to prevent page and table-level locks.

ms189099.note(en-us,SQL.100).gifNote:
In SQL Server, dynamic cursor worktable updates are always in place. That is, even if key columns are changed as part of the update, the current row is refreshed. In SQL Server 2000, the current row was marked as deleted (as it would have been for not-in-place keyset cursors), but the row was not inserted at the end of the worktable (as it was for keyset cursors). The result was that the cursor refresh failed to find the row and reported it missing. SQL Server keeps the cursor worktable in sync, and the refresh is able to find the row because it has the new keys.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker