思迅的E店通10,销售流水迁移至Eshop10的语句。
declare m_cursor cursor scroll for
select a.com_no from eStore10_xyj..t_rm_saleflow a left join ESXYJLSCS..t_rm_saleflow b
on a.flow_no =b.flow_no and a.flow_id =b.flow_id
where b.flow_no is null
open m_cursor
declare @com_no int
fetch next from m_cursor into @com_no
while @@FETCH_STATUS=0
begin
INSERT INTO [ESXYJLSCS].[dbo].t_rm_saleflow
([flow_no]
,[flow_id]
,[branch_no]
,[item_no]
,[sale_qnty]
,[source_price]
,[sale_price]
,[discount]
,[sale_money]
,[sell_way]
,[oper_id]
,[sale_man]
,[sale_rate]
,[oper_date]
,[shift_no]
,[item_flag]
,[spec_flag]
,[pref_amt]
,[vip_price]
,[in_price]
,[cost_price]
,[acc_num]
,[dec_rate]
,[card_id]
,[card_no]
,[pro_id]
,[com_flag]
,[memo]
,[plan_no]
,[item_sn]
,[vip_acc]
,[item_barcode]
,[produce_date]
,[valid_date]
,[item_rate]
,[cls_rate]
,[brand_rate]
,[dpfm_type]
,[irate_branch]
,[brate_branch]
,[crate_branch]
,[giftcert_no]
,[kz_flag]
,[update_date]
,[record_no]
,[weight_num]
,[real_shift_no]
,[shift_date]
,[share_cardid])
select A.[flow_no]
,A.[flow_id]
,LTRIM(RTRIM(a.[branch_no]))+'01'
,A.[item_no]
,A.[sale_qnty]
,A.[source_price]
,A.[sale_price]
,1
,A.[sale_money]
,A.[sell_way]
,A.[oper_id]
,A.[sale_man]
,0
,A.[oper_date]
,A.[shift_no]
,B. combine_sta
,A.[spec_flag]
,A.[pref_amt]
,B.[vip_price]
,A.[in_price]
,A.[in_price]
,0
,0
,null
,null
,0
,0
,null
,null
,null
,0
,''
,null
,null
,null
,null
,null
,[dpfm_type]
,0
,0
,0
,0
,1
,oper_date
,null
,0
,null
,oper_date
,null
from eStore10_xyj..t_rm_saleflow A
LEFT JOIN eStore10_xyj ..t_bd_item_info B ON A.item_no = B.ITEM_NO
where A.com_no = @com_no
fetch next from m_cursor into @com_no
end
close m_cursor
deallocate m_cursor