为了账号安全,请及时绑定邮箱和手机立即绑定

关键字 'for' 附近有语法错误?

关键字 'for' 附近有语法错误?

慕姐4208626 2022-09-16 11:11:31
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

查看完整回答
反对 回复 2022-09-21
?
智慧大石

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


查看完整回答
反对 回复 2022-09-21
  • 2 回答
  • 0 关注
  • 179 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信