请加大家一个问题,我在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