shadonar
shadonar

Reputation: 1194

Sql Server Cursor error on 'for'

here's the sql code I have for a cursor I need:

declare @myCursor cursor for
    SELECT item_one, item_2, lastUpdateTime, content_value FROM #MyTable;

I'm getting the error:

Msg 156, Level 15, State 1, Line 44 Incorrect syntax near the keyword 'for'.

What am I doing wrong?

I'm using SQL Server 2008 R2.

Upvotes: 2

Views: 608

Answers (1)

Hart CO
Hart CO

Reputation: 34784

Cursors do not use a @ prefix like other variables:

declare myCursor cursor for
    SELECT item_one, item_2, lastUpdateTime, content_value FROM #MyTable;

Upvotes: 5

Related Questions