创建脚本时出现 SQL 错误
我在一个表上使用了 SQL Server Management Studio,并通过 Create Script to New 进行了一些细微的更改。 给我一个错误“WITH”之后的“(”附近的语法不正确
/* EventType Table Creation */
CREATE TABLE [EventType]
(
[pkEventID] [int] IDENTITY(1,1) NOT NULL,
[Description] [nvarchar](50) NOT NULL,
[BeginDate] [datetime] NOT NULL,
[EndDate] [datetime] NOT NULL,
[Comments] [nvarchar](500) NOT NULL,
CONSTRAINT [PK_EventType] PRIMARY KEY
CLUSTERED
(
[pkEventID] ASC
)
WITH
(
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
)
ON [PRIMARY]
)
ON [PRIMARY]
GO
I used the SQL Server management studio on a table with Create Script to New and did minor changes. Give me an error "Incorrect syntax near '('" for the "(" after "WITH"
/* EventType Table Creation */
CREATE TABLE [EventType]
(
[pkEventID] [int] IDENTITY(1,1) NOT NULL,
[Description] [nvarchar](50) NOT NULL,
[BeginDate] [datetime] NOT NULL,
[EndDate] [datetime] NOT NULL,
[Comments] [nvarchar](500) NOT NULL,
CONSTRAINT [PK_EventType] PRIMARY KEY
CLUSTERED
(
[pkEventID] ASC
)
WITH
(
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
)
ON [PRIMARY]
)
ON [PRIMARY]
GO
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在针对哪个版本的 Microsoft SQL Server 执行此
CREATE TABLE
语句? 根据文档,MS SQL Server 2000 无法识别WITH (...index options...)
的语法。 MS SQL Server 2005 及更高版本支持该语法。即使您使用 SQL Managment Studio 2005,您也可能会连接到 MS SQL Server 2000。要验证版本,请尝试以下查询:
MS SQL Server 2000 的
productversion
是 8.x。MS SQL Server 2005 的
产品版本
是9.x。MS SQL Server 2008 的
产品版本
是 10.x。Which version of Microsoft SQL Server are you executing this
CREATE TABLE
statement against? According to documentation, MS SQL Server 2000 does not recognize the syntax forWITH (...index options...)
. That syntax is supported in MS SQL Server 2005 and later.Even if you use SQL Managment Studio 2005, you may be connecting to MS SQL Server 2000. To verify the version, try this query:
MS SQL Server 2000's
productversion
is 8.x.MS SQL Server 2005's
productversion
is 9.x.MS SQL Server 2008's
productversion
is 10.x.