8

我已经检查了好几次。列计数匹配但我不断收到错误消息,说 fetch into 语句与计数不匹配

declare cur_range CURSOR FOR
SELECT 
GroupID,
OddEven,
RangeLow,
RangeHigh
PostCode1,
PostCode2,
ID,
OldPrimaryID,
ThFareID
FROM tmpNewPrimaryRange;    

OPEN cur_range

FETCH NEXT FROM cur_range
into
 @cur_GroupID
 , @cur_OddEven
 , @cur_RangeLow
 , @cur_RangeHigh
 , @cur_PostCode1
 , @cur_PostCode2
 , @cur_ID
 , @cur_OldPrimaryID
 , @cur_ThFareID

错误:Cursorfetch:INTO 列表中声明的变量数量必须与所选列的数量匹配。

4

1 回答 1

19

如果您在列之前或之后的逗号位置保持一致,您可能已经发现了这一点:

declare cur_range CURSOR FOR
SELECT 
GroupID,
OddEven,
RangeLow,
RangeHigh    --- <-- ******* NO COMMA HERE ******
PostCode1,
PostCode2,
ID,
OldPrimaryID,
ThFareID

这是在说SELECT ... RangeLow, RangeHigh AS PostCode1, PostCode2 ...

于 2013-08-21T17:20:03.713 回答