--插入所需数据
insert INTO xtsw_ym.dbo.splsk
select plh, dj_sn, spid, rq, dwbh, yishj, yjzh, djbh, bm, ywy, '', zhy, jzhh, hw, pihao, rkshl, rkdj, rkje, chkshl, chkje, xshe, xshje, ml, jcshl, jcje, chbdj, lshj, hwjcsh, hwjcer, plcj, '', bendian, '', '0.00'
from openrowset( 'SQLOLEDB', '192.168.16.237'; 'SA'; 'zdyysm,.',ymksoa.dbo.splsk)
where (djbh like 'jha%' or djbh like 'jhc%' or djbh like 'xsa%' or djbh like 'xsc%')
and spid in (select spid From spkfk where shengccj like '%广州白云山和记黄埔中药有限公司%') and rq>='2018-12-26' and rq<='2019-02-19'
order by plh
--检查数据条目
select * From splsk where djbh like 'xs%' and spid in (select spid From spkfk where shengccj like '%广州白云山和记黄埔中药有限公司%')
--删除相应数据
delete a from splsk a,fr_splskbys190219 b,spkfk c where b.备注1='删除' and a.djbh=b.单据编号 and a.spid=c.spid and b.商品编号=c.spbh and a.chkshl=b.数量 and a.pihao=b.批号
---变更数据
select xshe/xshje,xshe/chkshl,chkshl,xshe,xshje,* from splsk where djbh in ('XSAYMA00326092') and spid in (select spid From spkfk where shengccj like '%广州白云山和记黄埔中药有限公司%')
select * From mchk where danwbh in ('XSZD02869','XSZD00019','XSZD01517','XSZD00376')
update splsk set dwbh='DWI00000160' where djbh in ('XSAYMA00321322','XSAYMA00323252','XSAYMA00322730','XSAYMA00326695','XSAYMA00326695','XSAYMA00326772','XSAYMA00326772')
update splsk set dwbh='DWI00000862' where djbh in ('XSAYMA00323072') and spid='SPH00000099'
update splsk set dwbh='DWI00013329' where djbh in ('XSAYMA00319245') and spid='SPH00000099'
update splsk set dwbh='DWI00005650' where djbh in ('XSAYMA00322823') and spid='SPH00000099'
update splsk set chkshl=-500,xshe=75chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00319889') and spid='SPH00019860'
update splsk set chkshl=662,xshe=14.04chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00319155') and spid='SPH00016850'
update splsk set chkshl=82,xshe=13chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00320299') and spid='SPH00010963'
update splsk set chkshl=1,xshe=8.67chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00320602') and spid='SPH00007030'
update splsk set chkshl=120,xshe=11.5chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00320827') and spid='SPH00000185'
update splsk set chkshl=3307,xshe=11.5chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00320993') and spid='SPH00000185'
update splsk set chkshl=600,xshe=27.5chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00321322') and spid='SPH00000099'
update splsk set chkshl=-1250,xshe=76chkshl,xshje=xshe/1.16,pihao='H18A010' where djbh in ('XSAYMA00321710') and spid='SPH00019860' and dj_sn=2
update splsk set chkshl=2800,xshe=27.5chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00323072') and spid='SPH00000099'
update splsk set chkshl=944,xshe=27.5chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00323252') and spid='SPH00000099'
update splsk set chkshl=120,xshe=11.5chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00324716') and spid='SPH00000185'
update splsk set chkshl=60,xshe=12.08chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00327868') and spid='SPH00000185'
update splsk set chkshl=-20,xshe=27.5chkshl,xshje=xshe/1.16 where djbh in ('XSCYMA00034799') and spid='SPH00000099'
update splsk set chkshl=-1150,xshe=76chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00326092') and spid='SPH00019860' and dj_sn=4
update splsk set chkshl=-150,xshe=76*chkshl,xshje=xshe/1.16 where djbh in ('XSAYMA00326092') and spid='SPH00019860' and dj_sn=3
select * From splsk where spid in
(select spid From spkfk where shengccj like '%广州白云山和记黄埔中药有限公司%')
and djbh like 'xs%' and chkshl<0 and zhy='销售出库单'
order by rq desc
update splsk set zhy='销售退回入库单',djbh=replace(djbh,'XSA','XSC') where spid in
(select spid From spkfk where shengccj like '%广州白云山和记黄埔中药有限公司%')
and djbh like 'xs%' and chkshl<0 and zhy='销售出库单'