如何解决 在关键字 'else' 附近有语法错误

我心依旧2014 我心依旧2014 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
drop table rkpc

create table rkpc(id int, name varchar(10), idnum int,户主 varchar(10))
insert into rkpc values(1 , '张三' , 434300 ,null)
insert into rkpc values(2 , '张三老婆', null ,null)
insert into rkpc values(3 , '张三女儿', null ,null)
insert into rkpc values(4 , '李四' , 434311 ,null)
insert into rkpc values(5 , '李四老婆', null ,null)
insert into rkpc values(6 , '李四儿子', null ,null)
go


select * FROM RKPC


declare @id int,@idnum char(30)
declare cur cursor fast_forward for
select int,innum from rkpc;
fetch next from cur into @id,@idnum;
open cur


if IDNUM IS NOT NULL

begin
update rkpc set 户主='是'
where id=@id

else

update rkpc set 户主='否'
where id=@id;
fetch next from cur into @id,@idnum;
end
close cur




服务器: 消息 156,级别 15,状态 1,行 14
在关键字 'else' 附近有语法错误。


这个是怎么回事
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
我心依旧2014
MS-SQL Server 34,876 成员 254,635 内容