日期:2014-05-18 浏览次数:20556 次
--我改了一条数据
declare @PURTH table (TH001 int,TH002 int,TH054 numeric(11,6))
insert into @PURTH
select 3401,2011060038,200.000000 union all
select 3401,2011060039,5000.000000 union all
select 3401,2011060044,3000.000000 union all
select 3401,2011060045,50.000000 union all
select 3401,2011070001,1.000000 union all
select 3401,2011060026,10000.000000 union all
select 3498,2011060004,56.100000 union all
select 3498,2011060005,10150.000000
declare @ACPTB table (TB005 int,TB006 int)
insert into @ACPTB
select 3401,2011060038 union all
select 3498,2012010002 union all
select 3498,2011120007 union all
select 3498,2012020001 union all
select 3498,2012020001 union all
select 3498,2011100015 union all
select 3498,2011110010 union all
select 3498,2011120006
update @PURTH set TH054=0 from @PURTH a left join @ACPTB b
on a.TH001=b.TB005 and a.TH002=b.TB006 where b.TB005 is null
select * from @PURTH
/*
TH001 TH002 TH054
----------- ----------- ---------------------------------------
3401 2011060038 200.000000
3401 2011060039 0.000000
3401 2011060044 0.000000
3401 2011060045 0.000000
3401 2011070001 0.000000
3401 2011060026 0.000000
3498 2011060004 0.000000
3498 2011060005 0.000000
*/