在sqlserver的存储过程中怎样使用if-else if

如题所述

if a>b
Begin
   print 'a'
End
Else if a<b
Begin
   print 'b'
End
Else 
Begin
    print '代码' 
End


if-else语法为,最好不要把begin end省略掉。否则,存储过程比较长可能会报语法错误

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-12-13
直接用啊
create proc myProc @i int
as
if @i=1
select @i+10
else if @i=2
select @i+20
else
select 0