当前位置: 代码迷 >> Sql Server >> 高人来帮小弟我看一下存储过程报错
  详细解决方案

高人来帮小弟我看一下存储过程报错

热度:257   发布时间:2016-04-27 19:26:20.0
高人来帮我看一下存储过程报错
ELSE IF upper(@Msg)='DB'
BEGIN
DEClare @Dcoin int
DEClare @tmpQ tinyint
EXEC querryDB @A,@B,@TmpQ output
IF @TmpQ=0
select @Dcoin=Dcoin from userinfo where [email protected] and @B=B
SET @[email protected] +''
ELSE if @TmpQ=1
SET @SendMsg='对不起,没有相关匹配'
ELSE
SET @SendMsg='对不起,系统查询出错,请稍后查询!'
END

为什么分析查询的时候显示"EXEC querryDB @A,@B,@TmpQ output"这一行
服务器: 消息 156,级别 15,状态 1,过程 Service,行 133
在关键字 'ELSE' 附近有语法错误。

------解决方案--------------------
IF @TmpQ=0
BEGIN---- 加上
select @Dcoin=Dcoin from userinfo where [email protected] and @B=B 
SET @SendMsg= '您的帐户为 [email protected] + ' ' 
END----结构被破坏了

------解决方案--------------------
EXEC querryDB @A,@B,@TmpQ output 
这句是啥来的。没看懂

至于else那里,跟楼上意见一样。
在sql中用if...else..时,如果只有一条语句可以不用写begin..end。但超过一条。必须加上begin..,,end
  相关解决方案