--单据对照表 if exists (select * from sysobjects where id = object_id('dbo.usp_datamaps') ) drop view dbo.usp_datamaps go Create view usp_datamaps as select '其他入库单' as vouchertype,ccode,newcode,ddate,importdate,processdate, case when direction=1 then '旺店通到U8' else 'U8到旺店通' end as transtype from rdrecord08 union select '其他出库单' as vouchertype,ccode,newcode,ddate,importdate,processdate, case when direction=1 then '旺店通到U8' else 'U8到旺店通' end as transtype from rdrecord09 union select '采购入库单' as vouchertype,ccode,newcode,ddate,importdate,processdate, case when direction=1 then '旺店通到U8' else 'U8到旺店通' end as transtype from rdrecord01 union select '采购退货单' as vouchertype,ccode,newcode,ddate,importdate,processdate, case when direction=1 then '旺店通到U8' else 'U8到旺店通' end as transtype from PU_ArrivalVouch union select '销售退货单' as vouchertype,cdlcode as ccode,newcode,ddate,importdate,processdate, case when direction=1 then '旺店通到U8' else 'U8到旺店通' end as transtype from dispatchlist union select '销售订单' as vouchertype,csocode as ccode,newcode,ddate,importdate,processdate, case when direction=1 then '旺店通到U8' else 'U8到旺店通' end as transtype from so_somain union select '采购订单' as vouchertype,cpoid as ccode,newcode,dpodate as ddate,importdate,processdate, case when direction=1 then '旺店通到U8' else 'U8到旺店通' end as transtype from po_pomain go