alter  PROCEDURE QSP_GET_BACK_SIGN
 
  @site  varchar(20)
 AS
 
 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

declare @b3 int
declare @b4 int
SELECT @b3=b3,@b4=b4 FROM b_arg 
 
SELECT
         0 as ischecked,          
         a.unit,   
         a.billno,   
         a.billdate,   
         a.bsite,   
         a.esite,
         a.address,
         a.state,
         a.shipper,
		 a.tyddate,
         a.consignee,   
         a.product,   
         a.qty,         
         backqty,
   s1=case when isnull(fetchdate,'')<>'' then 1 else 0 end,
s2=case when isnull(modifyremark,'')<>'' then 1 else 0 end,
s3=case when isnull(isbad,0)>0 then 1 else 0 end,
s4=case when isnull(outinoneflag,'')='' then 0 else 1 end,
         acctype,
        accnow,accarrived,accback,accmonth,accdaishou,acczz,accsend,
        webid  ,createby,outcygs,outdate,  acctype,shippertel,shippermb,a.middlesite,outbillno,vipno,addr,weight,volumn,fapiaono,shippercompany,consigneecompany,acchuokuankou,acctotal,acctax
    FROM B_TYD as a left join b_tyd_trace_tpl as b on (a.unit=b.unit)   
WHERE 
(
 a.esite = @site or a.middlesite = @site or (a.bsite=@site and @b4=1)

or (a.bsite = @site AND ((a.state=10 AND tosite=0) or okprocess='司机直送'))

)
AND signdate is null AND isnull(backrecipient,'')=''
AND isnull(a.backqty,'') <>''  AND a.state<>100 AND a.state<>11

原文地址: https://www.cveoy.top/t/topic/op6r 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录