--/*******採購入庫登記單位商品關係
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
if @djlxbs= '116'
begin
create table #t_dwsp (
dwbh char (11) null default '' ,
spid char (11) null default '' ,
spid1 char (11) null default ''
)
insert into #t_dwsp(dwbh,spid,spid1)
select @dwbh,a.spid, isnull (b.spid, '@#$%^&*@#$%' ) as spid1 from #t_djmx a
left join wyf_dwspgx b(nolock) on a.spid=b.spid and b.dwbh=@dwbh
insert into wyf_dwspgx(dwbh,spid) select dwbh,spid from #t_dwsp where spid1= '@#$%^&*@#$%'
drop table #t_dwsp
--刪除缺貨登記
insert into xsqhdj_his(rq,spid,shl,dwbh,username,beizhu) select rq,spid,shl,dwbh,username,beizhu from xsqhdj where spid in ( select distinct spid from #t_djmx)
delete from xsqhdj where spid in ( select distinct spid from #t_djmx)
end
|