/第一步:插入除了手機的商品資訊到檔案/
declare @sql varchar(max)
set @sql=(select max(fentryid) fentryid from paez_t_xs***x where fentryid>1)
--insert into paez_t_xs***x(f_entryid_jf,fid,fentryid,f_paez_date,f_paez_djlx,f_paez_md,f_paez_price,f_paez_spdm,f_paez_spmc1,f_paez_xsfbillno,f_paez_xsje,f_paez_xssl,f_paez_qy)
select fentryid,t16.fid,isnull(@sql,'1001')+row_number() over(order by t0.fbillno) ggg,convert(varchar(10),t0.f_pbka_date,21),t12.fname,t11.fname,fdiscountprice,t2.fnumber,t3.fname,t0.fbillno,case when t0.fbilltypeid='57faf492b10d31'
then fsdjamount else -fsdjamount end,case when t0.fbilltypeid='57faf492b10d31' then fqty else -fqty end ,tbtp.fname
from (select fid,f_pbka_date,fbilltypeid,folddepartment,rtrim(ltrim(f_pbka_phone)) f_pbka_phone,fbillno from pbka_t_billhead where fid>1) t0
left join(select fid,fsdjamount,fqty,fmaterialid,fdiscountprice,fentryid from pbka_t_goodsdetail where fentryid>1) t1 on t0.fid=t1.fid
left join (select fid,flocaleid from pbka_t_billhead_l where fid>1) t10 on t0.fid=t10.fid and t10.flocaleid=2052
left join (select fmaterialid,fnumber from t_bd_material where fmaterialid>1) t2 on t1.fmaterialid=t2.fmaterialid
left join (select fmaterialid,fname from t_bd_material_l where fmaterialid>1 and flocaleid=2052) t3 on t1.fmaterialid=t3.fmaterialid
inner join (select fdeptid,fname from t_bd_department_l where fdeptid>1 and flocaleid=2052) t11 on t0.folddepartment=t11.fdeptid
inner join (select fbilltypeid,fname from t_bas_billtype_l where flocaleid=2052) t12 on t0.fbilltypeid =t12.fbilltypeid
inner join (select fmobilephone,fid from t_ecc_member where fid>1) t16 on f_pbka_phone=t16.fmobilephone
left join (select fcategoryid,fmaterialid from t_bd_materialbase where fcategoryid>1) m on m.fmaterialid=t2.fmaterialid
inner join (select fdeptid,fgroup from t_bd_department) tbt on tbt.fdeptid=t11.fdeptid
inner join (select fdeptid,fname from t_bd_department_l where flocaleid=2052) tbtl on tbt.fdeptid=tbtl.fdeptid
inner join (select fid,fname from t_bd_departgroup_l where flocaleid=2052) tbtp on tbt.fgroup=tbtp.fid
where (t0.fbilltypeid ='580778655b6d7d' or t0.fbilltypeid ='57faf492b10d31') and m.fcategoryid<>'2092334' and fdiscountprice<>0
and not exists (select f_entryid_jf from paez_t_xs***x where f_entryid_jf<>'' and t1.fentryid=f_entryid_jf)
and (convert(varchar(10),t0.f_pbka_date,21)>=convert(varchar(10), '2018-02-01', 21) and convert(varchar(10),t0.f_pbka_date,21)<=convert(varchar(10), '2018-02-24', 21) )
--and fbillno='lsd180101393327'
order by fbillno
/第二步:/
---取今天的資料
select (select max(fid) fid from t_ecc_member)+row_number() over(order by fbillno) ggg
,'hy'+substring(t0.fbillno,3,20) xuhao,
f_pbka_name,fbillno,
rtrim(ltrim(f_pbka_phone)) f_pbka_phone,f_pbka_oldsalorgid,'1001' fmembertypeid,'1002' fmemberlevelid,'c' fdocumentstatus,
fcreatorid,fcreatedate,fcreatorid fcreatorids,fcreatedate fcreatedates,f_pbka_client,f_pbka_id
into #uuu
from (select fbillno,rtrim(ltrim(f_pbka_phone)) f_pbka_phone,f_pbka_oldsalorgid,f_pbka_client,f_pbka_id,fcreatedate,fcreatorid,fid from pbka_t_billhead where fid>1) t0
left join (select fid,f_pbka_name from pbka_t_billhead_l where fid>1) t10 on t0.fid=t10.fid
where f_pbka_phone<>'' and f_pbka_phone not in(select distinct fmobilephone from t_ecc_member)
and convert(varchar(10),fcreatedate,21)=convert(varchar(10), getdate(), 21)
------顧客資料表去重**插入臨時表--------
create table #dh (f_pbka_phone varchar(100))
insert into #dh
select distinct rtrim(ltrim(f_pbka_phone)) from #uuu
-------把要插入顧客資料表的資訊去重處理----
create table #qc(fbillno varchar(100),f_pbka_phone varchar(100))
insert into #qc
select distinct max(fbillno) fbillno,f_pbka_phone from #uuu group by f_pbka_phone order by 2
---最終要插入的資料
select a.ggg, xuhao,a.fbillno,f_pbka_name,a.f_pbka_phone,f_pbka_oldsalorgid,fmembertypeid,fmemberlevelid,fdocumentstatus,fcreatorid,fcreatedate,fcreatorid fcreatorids,fcreatedate fcreatedates,f_pbka_client,f_pbka_id
into #uuu1
from #uuu a
inner join #qc b on a.fbillno=b.fbillno and a.f_pbka_phone=b.f_pbka_phone
select f_pbka_name,ggg,xuhao,f_pbka_phone,f_pbka_oldsalorgid,fmembertypeid,fmemberlevelid,fdocumentstatus,fcreatorid,fcreatedate,fcreatorid fcreatorids,fcreatedate fcreatedates,f_pbka_client,f_pbka_id
into #uuu2
from #uuu1
where f_pbka_phone not in(select distinct fmobilephone from t_ecc_member)
linux 更新系統時間
1.ntpdate 命令更新時間 ntpdate asia.pool.ntp.org 2.date 命令更新時間 例 更新時間為 10年12月13日 date s 101213 更新時間為 14 20 00 date s 14 20 00 更新時間為 2010 12 13 14 26 date s ...
linux更新系統時間
檢查是否安裝過ntp rpm aq grep ntp 如果沒有裝用 yum install ntp 完成後 ntpdate time.windows.com讓系統時間和bios時間同步,用hwclock命令就行了命令列裡打 hwclock systohc或者這個命令的簡寫hwclock w就可以讓b...
windows更新系統系統時無法更新
win7系統顯示 windows update當前無法檢查更新,因為未執行服務,您可能需要重新啟動計算機 解決方法 1 win r開啟執行視窗,輸入cmd 2 在dos視窗中輸入命令 net stop wuauserv 並回車,來停止windows update服務。3 再次開啟執行視窗 4 找到s...