日期:2014-05-17  浏览次数:20417 次

求高手 帮助

if OBJECT_ID('tempdb.dbo.#bus_BusinessDetail') is not null drop table #bus_BusinessDetail
if OBJECT_ID('tempdb.dbo.#cost_FeeInfo') is not null drop table #cost_FeeInfo
if OBJECT_ID('tempdb.dbo.#customs_CustomsDeclaration') is not null drop table #customs_CustomsDeclaration
CREATE TABLE [#bus_BusinessDetail](     
[Id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[BusinessNum] [varchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,     
[Consignor] [varchar](100) COLLATE Chinese_PRC_CI_AS NULL,  
CONSTRAINT [PK_BUS_BUSINESSDETAIL] PRIMARY KEY NONCLUSTERED  
(     [Id] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY]   


CREATE TABLE [#cost_FeeInfo](     
[Id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[BusinessNum] [varchar](20) COLLATE Chinese_PRC_CI_AS NULL,     
[Flag_ManagerCheckCost] [varchar](1) COLLATE Chinese_PRC_CI_AS NULL,  
CONSTRAINT [PK_COST_FEEINFO] PRIMARY KEY NONCLUSTERED  (     [Id] ASC)
WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] )   


CREATE TABLE [#customs_CustomsDeclaration](    
[Id] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
 [BusinessNum] [varchar](20) COLLATE Chinese_PRC_CI_AS NULL,     
 [AdvanceNum] [varchar](20) COLLATE Chinese_PRC_CI_AS NULL,     
 [DeclareDate] [datetime] NULL,     
 [DeliveryListNum] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,     
 [Declare_Name] [varchar](10) COLLATE Chinese_PRC_CI_AS NULL,  
 CONSTRAINT [PK_CUSTOMS_CUSTOMSDECLARATION] PRIMARY KEY NONCLUSTERED  (     [Id] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] 
----------------------------------------------------------
insert into #bus_BusinessDetail(BusinessNum,Consignor) 
values ('RPO201310000001','A公司')
insert into #bus_BusinessDetail(BusinessNum,Consignor) 
values('RPI201310000015','B公司')
insert into #bus_BusinessDetail(BusinessNum,Consignor) 
values('RPI201310000016','A公司')
insert into #bus_BusinessDetail(BusinessNum,Consignor) 
values('BPO103942','A公司')
insert into #bus_BusinessDetail(BusinessNum,Consignor) 
values('YLO201310001539','A公司')
------------------------------------------------------------
insert into #cost_FeeInfo ([BusinessNum],[Flag_ManagerCheckCost])
values ('RPO201310000001','0')
insert into #cost_FeeInfo ([BusinessNum],[Flag_ManagerCheckCost])
values('RPO201310000001','0')
insert into #cost_FeeInfo ([BusinessNum],[Flag_ManagerCheckCost])
values('RPI201310000015','0' )
insert into #cost_FeeInfo ([BusinessNum],[Flag_ManagerCheckCost])
values('RPI201310000015','1' )
insert into #cost