update A set a2 = 1 where a1 in (select b1 from B)
看来是我想复杂了 我写了段东西来完成 declare @i varchar(20) --declare @y varchar(100) select @i=count(*) from b shit: if(@i>0) begin
--SET @y='select top '+@i+' b from b' if(select count(*) from a where a1 in (select top 1 b from b where b not in (select top '+@i+' b from b)))=0 begin
GOTO shit1 end else begin set @i=@i-1 GOTO shit end end shit1: select @i 但是top后面不能跟参数 所以就没办法了
set a2 = 1
where a1 in (select b1 from B)
我写了段东西来完成
declare @i varchar(20)
--declare @y varchar(100)
select @i=count(*) from b
shit:
if(@i>0)
begin
--SET @y='select top '+@i+' b from b'
if(select count(*) from a where a1 in (select top 1 b from b where b not in (select top '+@i+' b from b)))=0
begin
GOTO shit1
end
else
begin
set @i=@i-1
GOTO shit
end
end
shit1:
select @i
但是top后面不能跟参数 所以就没办法了