if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_销售记录表_客户信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[销售记录表] DROP CONSTRAINT FK_销售记录表_客户信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_房间信息表_楼房信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[房间信息表] DROP CONSTRAINT FK_房间信息表_楼房信息表
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_销售记录表_房间信息表1]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[销售记录表] DROP CONSTRAINT FK_销售记录表_房间信息表1
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[客户信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[客户信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[楼房信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[楼房信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[房间信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[房间信息表]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[销售记录表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[销售记录表]
GO
CREATE TABLE [dbo].[客户信息表] (
[customerID] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[sex] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[birth] [datetime] NULL ,
[marital] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[members] [int] NULL ,
[jobs] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[identification] [char] (18) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[income] [float] NULL ,
[telephone] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[address] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[remarksc] [text] COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[楼房信息表] (
[buildingID] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[bdname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[bdposition] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[area] [float] NULL ,
[investment] [float] NULL ,
[layers] [int] NULL ,
[roomN] [int] NULL ,
[bdintroduction] [text] COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[房间信息表] (
[roomID] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[buildingID] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[rmposition] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
[rmsize] [float] NULL ,
[type] [char] (8) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[status] [char] (6) COLLATE Chinese_PRC_CI_AS NULL ,
[rmintroduction] [text] COLLATE Chinese_PRC_CI_AS NULL ,
[cost] [float] NULL ,
[price] [float] NULL ,
[discountrate] [float] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[销售记录表] (
[saleID] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[roomID] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[buildingID] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[customerID] [char] (4) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[cost] [float] NOT NULL ,
[price] [float] NOT NULL ,
[discountrate] [float] NOT NULL ,
[profit] [float] NOT NULL ,
[payment] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[datetransaction] [datetime] NOT NULL ,
[remarkssale] [text] COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO