You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/word/新协航_设计文档/数据库建表文档/1.0/KC.sql

52 lines
1.4 KiB
Transact-SQL

/****** Object: Table [dbo].[Import_KC] Script Date: 10/07/2013 14:40:40 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Import_KC]') AND type in (N'U'))
DROP TABLE [dbo].[Import_KC]
GO
/****** Object: Table [dbo].[Import_KC] Script Date: 10/07/2013 14:40:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Import_KC](
[id] [int] IDENTITY(1,1) NOT NULL,
[ContractNo] [varchar](50) NOT NULL,
[cargo_id] [int] NOT NULL,
[CZState] [tinyint] NOT NULL default 0,
[InNum] [numeric](8, 2) NOT NULL default 0,
[OutNum] [numeric](8, 2) NOT NULL default 0,
[KFstate] [tinyint] NOT NULL default 0,
[CZdate] datetime null,
[text] [varchar](150) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
--³õʼ»¯¿â´æ
delete from [Import_KC] where cargo_id=1
insert into [Import_KC]
select
[ContractNo],id [cargo_id],0 [CZState] ,
boxcount as [InNum],0 [OutNum],
0 kcstate,(getdate()) kcdate,
'' [text]
from import_cargo where id=1
--ÏÔʾÁбí
select k.id,k.contractno,k.cargo_id,c.name,K.czstate,
k.innum,k.outnum,k.kfstate,k.czdate,k.[text],
t1.enumvaluename as czref,t2.enumvaluename as kfref
from [Import_KC] K
left join import_cargo c on c.id=k.cargo_id
left join tsysenumvalue t1 on t1.enumtypeid=8 and t1.enumvalueid=K.czstate
left join tsysenumvalue t2 on t2.enumtypeid=9 and t2.enumvalueid=K.kfstate