declare @PtnLimitTime datetimedeclare @cursor CURSOR forSelect PtnLimitTime from tblPlanTableNameopen @cursorfetch next from @cursor into @PtnLimitTimewhile(@@fetch_status=0)beginprint @PtnLimitTimefetch next from @cursor into @PtnLimitTimeendclose @cursordeallocate @cursor错误提示:消息 156,级别 15,状态 1,第 3 行关键字 'for' 附近有语法错误。错误提示:消息 156,级别 15,状态 1,第 2行关键字 'for' 附近有语法错误。弄错提示了。
2 回答
肥皂起泡泡
TA贡献1829条经验 获得超6个赞
把cursor名前面的@去掉,如下:
declare cursor_1 CURSOR for
Select PtnLimitTime from tblPlanTableName
open cursor_1
fetch next from cursor_1 into @PtnLimitTime
while(@@fetch_status=0)begin
print @PtnLimitTime
fetch next from cursor_1 into @PtnLimitTime
end
close cursor_1
deallocate cursor_1
智慧大石
TA贡献1946条经验 获得超3个赞
declare @PtnLimitTime datetime
declare cursor1 CURSOR for
Select PtnLimitTime from tblPlanTableName
open cursor1
fetch next from cursor1 into @PtnLimitTime
while(@@fetch_status=0)begin
print @PtnLimitTime
fetch next from cursor1 into @PtnLimitTime
end
close cursor1
deallocate cursor1
- 2 回答
- 0 关注
- 179 浏览
添加回答
举报
0/150
提交
取消