当前位置: 代码迷 >> Sql Server >> 新手请问存储过程的赋值!谢了~
  详细解决方案

新手请问存储过程的赋值!谢了~

热度:105   发布时间:2016-04-27 14:08:30.0
新手请教存储过程的赋值!谢了~~!
请加大家一个问题,我在t1中找IFlg字段,当IFlg值为1或者2时,@flg设定为1,[email protected]
[email protected]
请问像我这样写对不对?请各位高手指教!!!
谢了!!


begin
declare @i varchar(10)
declare @flg int


  select @i = IFlg 
  from Table1 t1, Table2 t2
  where t2.AcctMnc = @customerAccount
  and t2.BC = t1.BC
  and t2.AC = t1.AC


   
  if(@i = '1' || @i = '2')
  set @flg = 1

  else
  set @flg = 0
   
  select @flg flg
   
end
go

------解决方案--------------------
SQL code
create proc proc_name@customerAccount varchar(100),@flg  int outputasif exists(  select 1from Table1 t1, Table2 t2where t2.AcctMnc = @customerAccountand t2.BC = t1.BCand t2.AC = t1.AC and t1.IFlg in(1,2))set @flg=1else set @flg=0
  相关解决方案