日期:2014-05-18  浏览次数:20552 次

求解释语句。
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].[订货表] (
[订单编号] [int] IDENTITY (1, 1) NOT NULL ,
[书籍编号] [int] NOT NULL ,
[数量] [smallint] NOT NULL ,
[折扣] [real] NOT NULL ,
[单价] [money] NULL ,
[销售金额] AS ([单价] * [数量] * [折扣]) 
) ON [PRIMARY]
GO


------解决方案--------------------
SQL code

--如果存在订货表
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].[订货表] (
[订单编号] [int] IDENTITY (1, 1) NOT NULL , --自增列
[书籍编号] [int] NOT NULL ,
[数量] [smallint] NOT NULL ,
[折扣] [real] NOT NULL ,
[单价] [money] NULL ,
[销售金额] AS ([单价] * [数量] * [折扣])  --计算列
) ON [PRIMARY]
GO