Here is a snippet of my stored procedure:
/* First let's deal with the easiest table, the x table */
SELECT @numberOfRecords = Count(1) FROM x
/* Get the distinct sizes */
DECLARE Sizes CURSOR FOR SELECT DISTINCT Sizes FROM x
/* Reference the named cursor with a cursor variable. */
DECLARE @currentSize CURSOR
SET @currentRecord = 0
WHILE(@currentRecord < @numberOfRecords )
SET @currentSize = Sizes
SELECT @selectedDescription = Description FROM zlk_Size WHERE MinimumSize < @currentSize AND MaximumSize > @currentSize
UPDATE x SET Description = @selectedDescription WHERE Size = @currentSize
FETCH NEXT FROM Sizes
@currentRecord = @currentRecord + 1
when i check this with query analyzer i get this error:
Server: Msg 16949, Level 16, State 1, Procedure sp_BreakIntoClasses, Line 26
The variable '@currentSize' is a cursor variable, but it is used in a place where a cursor variable is not valid.
it is complaining about the line with the update statement. when i comment this line out though i get the same error on the same line!
what is going on here and how can i make this work?