Answers

Question and Answer:

  Home  MS SQL Server

⟩ How To Declare and Use Cursor Variables?

There are two ways to representing a cursor:

1. A cursor name - A static name representing a cursor object. A cursor name should be linked to a cursor object in the DECLARE statement.

2. A cursor variable name - A variable name pointing to a cursor object. A cursor variable name should be declared with the CURSOR data type. It should be then assigned with a cursor object using the SET statement.

The tutorial exercise below shows you how to declare a cursor variable and assign a cursor object to it:

USE GlobalGuideLineDatabase;

GO

-- declare a cursor variable

DECLARE @ggl_cursor CURSOR;

-- assign a cursor object

SET @ggl_cursor = CURSOR FOR

SELECT id, url, notes, counts, time FROM ggl_links;

 185 views

More Questions for you: