我想在我的数据库中创建一个额外的表:
CREATE TABLE "DEM_TRACE" (
"Id" NUMERIC(6),
"Indice" VARCHAR(3),
"Sec_Id" NUMERIC(10),
"QUOTE_PART_NUM" NUMERIC(38) DEFAULT 0,
"QUOTE_PART_DEN" NUMERIC(38) DEFAULT 1,
"OBSERV" NVARCHAR(250),
"DATE_CONV_BOR" DATETIME,
"DATE_RECE_CONV" DATETIME,
"CODE_DROIT" NUMERIC(3) DEFAULT 73,
"NOM_PA" NVARCHAR(50),
WITH NOCHECK CONSTRAINT CK_QUOTE_PART_1
CHECK(QUOTE_PART_NUM<=QUOTE_PART_DEN)
)
我希望在创建表格后禁用CK_QUOTE_PART_1
。当我在约束定义之前添加WITH NOCHECK
子句时,我收到Msg 156和Msg 319错误,指向我的代码的第11行(WITH NOCHECK CONSTRAINT CK_QUOTE_PART_1):
Message : Incorrect Syntax near the word WITH
我的代码有什么问题?
提前谢谢你:)
答案 0 :(得分:1)
如果你运行该怎么办?
CREATE TABLE "DEM_TRACE" (
"Id" NUMERIC(6),
"Indice" VARCHAR(3),
"Sec_Id" NUMERIC(10),
"QUOTE_PART_NUM" NUMERIC(38) DEFAULT 0,
"QUOTE_PART_DEN" NUMERIC(38) DEFAULT 1,
"OBSERV" NVARCHAR(250),
"DATE_CONV_BOR" DATETIME,
"DATE_RECE_CONV" DATETIME,
"CODE_DROIT" NUMERIC(3) DEFAULT 73,
"NOM_PA" NVARCHAR(50)
)
GO
ALTER TABLE [dbo]."DEM_TRACE" WITH NOCHECK ADD CONSTRAINT [CK_QUOTE_PART_1] CHECK NOT FOR REPLICATION ((QUOTE_PART_NUM<=QUOTE_PART_DEN))
GO
ALTER TABLE [dbo]."DEM_TRACE" NOCHECK CONSTRAINT [CK_QUOTE_PART_1]
GO
请注意,我删除了所有检查:有关创建,插入,更新和复制的现有数据。