/****** Object: Table [dbo].[Import_cargo] Script Date: 09/02/2013 14:12:49 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Import_cargo]') AND type in (N'U')) DROP TABLE [dbo].[Import_cargo] GO /****** Object: Table [dbo].[Import_cargo] Script Date: 09/02/2013 14:12:49 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Import_cargo]( [id] [int] IDENTITY(1,1) NOT NULL, [ContractNo] varchar(50) NOT NULL, [cargoinfo_id] [int] NOT NULL, [cargociq_id] [int] not null, [name] [varchar](50) NOT NULL, [Ename] [varchar](50) NULL, [UNIT] tinyint default 0 NULL,--重量单位 kg 磅 [U_PRICE] numeric(18,3) NULL,--重量单位 单价 [U_weight] [numeric](18, 3) NULL,----以重量单位计算的净重 [weight] [numeric](18, 3) NULL,--kg净重 [m_weight] [numeric](18, 3) NULL,--毛重(重量单位) [price] [numeric](18, 3) NULL,--价格(重量单价,以kg为单位) [price_agio] [numeric](18, 3) NULL,--差价(贸易商与客户价格之差,含义同price) [price_limit] [numeric](18, 3) NULL,--估价(海关估价/币种同价格币种) [Amount] [numeric](18, 3) NULL,--应收价格 weight*Price [tex_Amount] [numeric](18, 3) NULL,--估价价格 [pay_Amount] [numeric](18, 3) NULL,--应付价格 (price-price_agio)*price [BoxCount] [int] NULL,--箱/件数 [BoxWeight] [numeric](18, 3) NULL,--规格 [Exporter] [varchar](50) NULL,--出口商 [FactoryNo] [varchar](50) NULL,--厂号 [Productiondate] [varchar](250) NULL,--生产日期 [currid] varchar(50) null,--币别 关联code_currency [prepayments] [numeric](18, 3) NULL,--预付款 [balance] [numeric](18, 3) NULL,--尾款 [paypart] tinyint default 0, [baolv] numeric(8,4) default 1, [tariff] varchar(20) null, [tax] numeric(8,3) null, [tax_zz] numeric(8,3) null, [Declarenumber] varchar(50) null,--报关单号 [Exchangerate] numeric(18,4) default 1, -- [FinanceStatus] tinyint default 0, CONSTRAINT [PK_Import_cargo] PRIMARY KEY CLUSTERED ( [id] ASC ) ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name) values ('A1',1,1,'商品1') insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name) values ('A2',2,2,'商品2') insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name) values ('A3',3,3,'商品2_2') insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name) values ('A4',4,4,'商品2_3') SELECT c.*, (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=11 and EnumValueID=c.unit) as UnitRef, (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=12 and EnumValueID=c.paypart) as paypartRef, ci.code as cicode,ci.name as ciname,curr.codename,curr.defaultrate, ci.code+'_'+ci.name as cicodeandname, ciq.ciqcode as ciqcode,ciq.ciqname as ciqname, ciq.ciqcode+'_'+ciq.ciqname as ciqcodeandname --, --(select EnumValueName from tSysEnumValue where LangId=0 --and EnumTypeID=9000 and EnumValueID=cc.tariff) as tariff, --case cc.tariff when 0 then ci.tax_zhg when 1 then ci.tax_pt end tax, --ci.tax_zz FROM [ShippingWeb].[dbo].[Import_cargo] c left join [Import_cargoinfo] ci on c.[cargoinfo_id] = ci.id left join [Import_cargociq] ciq on c.[cargociq_id] = ciq.id left join [code_currency] curr on curr.gid=c.currid left join [import_main] m on M.contractno=c.contractno left join [code_country] cc on cc.countryid=m.countryid --输入hs代码 和/或 国家代码 查出关税税率和增值税税率 select code,name,code+'_'+name codeandname, countryid,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=9000 and EnumValueID=cc.tariff) as tariff, case cc.tariff when 0 then ci.tax_zhg when 1 then ci.tax_pt/100 end tax, ci.tax_zz/100 from code_country cc,import_cargoinfo ci where countryid='gb' /* BEGIN TRANSACTION SET QUOTED_IDENTIFIER ON SET ARITHABORT ON SET NUMERIC_ROUNDABORT OFF SET CONCAT_NULL_YIELDS_NULL ON SET ANSI_NULLS ON SET ANSI_PADDING ON SET ANSI_WARNINGS ON COMMIT BEGIN TRANSACTION GO ALTER TABLE dbo.Import_cargo DROP CONSTRAINT DF__Import_ca__Finan__1EA62536 GO ALTER TABLE dbo.Import_cargo DROP COLUMN FinanceStatus GO ALTER TABLE dbo.Import_cargo SET (LOCK_ESCALATION = TABLE) GO COMMIT */