先请看下面的代码:
if exists (select * from sysobjects where id = OBJECT_ID('[OA_GDZC_PJ]') and OBJECTPROPERTY(id, 'IsUserTable') = 1) DROP TABLE [OA_GDZC_PJ]
CREATE TABLE [OA_GDZC_PJ] ( [GZXH] [int] NOT NULL , [PJXH] [int] NOT NULL , [MC] [nvarchar] (50) NULL , [GMRQ] [nvarchar] (10) NULL , [GGXH] [nvarchar] (50) NULL , [SL] [smallmoney] NULL , [GHF] [nvarchar] (100) NULL , [BZ] [nvarchar] (255) NULL )
ALTER TABLE [OA_GDZC_PJ] WITH NOCHECK ADD CONSTRAINT [PK_OA_GDZC_PJ] PRIMARY KEY NONCLUSTERED ( [GZXH] )
CREATE UNIQUE CLUSTERED INDEX [PK_OA_GDZC_PJ] ON [OA_GDZC_PJ] ( [PJXH] )
这段代码是想通过SQL查询分析器,生成一个OA_GDZC_PJ表,其中GZXH、PJXH都设置为主键,可是在执行SQL分析器时,将出现 “表 'OA_GDZC_PJ' 已有一个名为 'PK_OA_GDZC_PJ' 的索引。”错误提出。
请高手指点。