SQL Server variable scope in a stored procedure

后端 未结 4 404
猫巷女王i
猫巷女王i 2020-12-03 11:02

I would like to declare a variable within an if/else statement in a SQL Server stored procedure. I understand that this is fairly impossible because SQL Server doesn\'t do m

4条回答
  •  -上瘾入骨i
    2020-12-03 11:24

    is there some reason why you can't do :

    declare @bob int 
    if exists(x) 
    begin   set @bob = 1 end 
    else 
    begin  set @bob = 2 end 
    

提交回复
热议问题