HOW TO USE CURSOR

DECLARE @VariableNames DATATYPE
DECLARE @CursorName CURSOR
SET @CursorName= CURSOR FOR datasource

OPEN @CursorName

FETCH NEXT  FROM @CursorName INTO @VariableNames
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT  ‘Do Something
FETCH NEXT FROM  @CursorName INTO @VaribaleNames
END

CLOSE  @CursorName
DEALLOCATE @CursorName

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.