I have a cursor defined as:
DECLARE idCursor CURSOR
FOR SELECT DISTINCT [id], [data]
FROM #tempTable
And I have a variable defined as:
DECLARE @currentId TABLE (
[id] int,
[data] char(1)
);
But when I try to fetch the next result into @currentId
FETCH NEXT FROM idCursor INTO @currentId
I get this error:
Must declare the scalar variable "@currentId".
How can I get the result of a cursor fetch in a table? I understand that I can declare two variables and store the results individually. But for a table with many columns that would be time consuming.