IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'FPMS')
	DROP DATABASE [FPMS]
GO

CREATE DATABASE [FPMS]  ON (NAME = N'hss_Data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL$SHUJUK\data\hss_Data.MDF' , SIZE = 2, FILEGROWTH = 10%) LOG ON (NAME = N'hss_Log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL$SHUJUK\data\hss_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)
 COLLATE Chinese_PRC_CI_AS
GO

exec sp_dboption N'FPMS', N'autoclose', N'false'
GO

exec sp_dboption N'FPMS', N'bulkcopy', N'false'
GO

exec sp_dboption N'FPMS', N'trunc. log', N'true'
GO

exec sp_dboption N'FPMS', N'torn page detection', N'true'
GO

exec sp_dboption N'FPMS', N'read only', N'false'
GO

exec sp_dboption N'FPMS', N'dbo use', N'false'
GO

exec sp_dboption N'FPMS', N'single', N'false'
GO

exec sp_dboption N'FPMS', N'autoshrink', N'true'
GO

exec sp_dboption N'FPMS', N'ANSI null default', N'false'
GO

exec sp_dboption N'FPMS', N'recursive triggers', N'false'
GO

exec sp_dboption N'FPMS', N'ANSI nulls', N'false'
GO

exec sp_dboption N'FPMS', N'concat null yields null', N'false'
GO

exec sp_dboption N'FPMS', N'cursor close on commit', N'false'
GO

exec sp_dboption N'FPMS', N'default to local cursor', N'false'
GO

exec sp_dboption N'FPMS', N'quoted identifier', N'false'
GO

exec sp_dboption N'FPMS', N'ANSI warnings', N'false'
GO

exec sp_dboption N'FPMS', N'auto create statistics', N'true'
GO

exec sp_dboption N'FPMS', N'auto update statistics', N'true'
GO

use [FPMS]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Biao_PeiZhi]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Biao_PeiZhi]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Biao_XinXiDian]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Biao_XinXiDian]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Biao_XuQiu]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Biao_XuQiu]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Biao_XuQiuFenLei]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Biao_XuQiuFenLei]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[hss_test]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[hss_test]
GO

CREATE TABLE [dbo].[Biao_PeiZhi] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[ShuJuZuKJM] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ShuJuZuKJLX] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ShuJuXiangMing] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ShuJuXiangKJM] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ShuJuXiangKJLX] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ZuiDaShuRuChangDu] [int] NOT NULL ,
	[ZhiDu] [varchar] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[MoRenZhi] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[XianShiShunXu] [int] NOT NULL ,
	[XiTongShuJu] [varchar] (2) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Biao_XinXiDian] (
	[XinXiDianBianHao] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[XinXiDianXiJie] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Biao_XuQiu] (
	[BianHao] [int] IDENTITY (1, 1) NOT NULL ,
	[CaiJiShiJian] [datetime] NOT NULL ,
	[TiChuRen] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[YuFuBianMa] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[XuQiuLeiBie] [varchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[DaFuRen] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[DaFuShiJian] [datetime] NULL ,
	[DaFuQingKuang] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[XinXiDianBianHao] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[XuQiuManYiDu] [float] NOT NULL ,
	[FUZHI1] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FUZHU3] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FUZHU5] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FUZHU6] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Biao_XuQiuFenLei] (
	[XuQiuDaMa] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[XuQiuDaMaMingXi] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[hss_test] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[name] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[code] [char] (10) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Biao_PeiZhi] WITH NOCHECK ADD 
	CONSTRAINT [PK_Biao_PeiZhi] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Biao_XinXiDian] WITH NOCHECK ADD 
	CONSTRAINT [PK_Biao_XinXiDian] PRIMARY KEY  CLUSTERED 
	(
		[XinXiDianBianHao]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Biao_XuQiu] WITH NOCHECK ADD 
	CONSTRAINT [PK_Biao_XuQiu] PRIMARY KEY  CLUSTERED 
	(
		[BianHao]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Biao_XuQiuFenLei] WITH NOCHECK ADD 
	CONSTRAINT [PK_Biao_XuQiuDaMa] PRIMARY KEY  CLUSTERED 
	(
		[XuQiuDaMa]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Biao_PeiZhi] WITH NOCHECK ADD 
	CONSTRAINT [DF_Biao_PeiZhi_ZhiDu] DEFAULT ('N') FOR [ZhiDu],
	CONSTRAINT [DF_Biao_PeiZhi_XiTongShuJu] DEFAULT ('N') FOR [XiTongShuJu]
GO

