--/*******采购入库登记单位商品关系
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
|
本文转自 qvodnet 51CTO博客,原文链接:http://blog.51cto.com/bks2015/1606039