What Is a Cursor?

A cursor is a SQL resultset that enables you to perform row-oriented operations on the resultset. (This differs from standard SQL resultsets, which return all the rows in the resultset.) This means that you can process data row by row. With SQL Server's cursors, you can navigate forward and backward through the resultset. You can really exploit the power of cursors when you combine them with the EXEC command and a string variable substitution.

Cursors can be used in the following locations:

  • In a control-of-flow batch

  • Within a stored procedure

  • Within a trigger

Get Microsoft® SQL Server™ 2000 DBA Survival Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.