Microsoft SQL Service Management Studio 2005“将 XXX 脚本编写为 CREATE To”问题

发布于 2024-08-07 07:57:51 字数 937 浏览 0 评论 0原文

当使用“脚本索引作为创建到”将索引从一个表复制到另一个表时,我无法运行该脚本。如果不编辑生成的代码,我会收到错误。在使用任何“Script XXX as CREATE To”生成的代码时,我遇到同样的错误。有任何意见/建议来解决这个问题吗?

错误:

消息 170,级别 15,状态 1,第 6 行 第 6 行:“(”附近的语法不正确。

脚本:

CREATE NONCLUSTERED INDEX [IX_IncidentStop_Note] ON [dbo].[IncidentStop_Note] 
(
    [IncidentStopID] ASC,
    [NoteID] ASC,
    [Active_Fl] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

编辑:

来自 Stuart Ainsworth 事实证明我处于 SQL Server 2000 (80) 兼容级别。我的问题稍微改变为,在 2005 年工作但兼容性级别为 2000 时,如何将某些内容从一个表复制到另一个表?

When using the 'Script Index as CREATE To' to duplicate an index from one table to another table I am not able to run the script. Without editing the generated code I get an error. I get the same error when working with any 'Script XXX as CREATE To' generated code. Any comments/suggestions to solve this problem?

ERROR:

Msg 170, Level 15, State 1, Line 6
Line 6: Incorrect syntax near '('.

SCRIPT:

CREATE NONCLUSTERED INDEX [IX_IncidentStop_Note] ON [dbo].[IncidentStop_Note] 
(
    [IncidentStopID] ASC,
    [NoteID] ASC,
    [Active_Fl] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

EDIT:

As from the answer from Stuart Ainsworth it turns out I am in SQL Server 2000 (80) Compatibility level. My question would slightly change to how can I duplicate something from one table to another while working in 2005 but having the compatibility level of 2000?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丶情人眼里出诗心の 2024-08-14 07:57:51

目标数据库的兼容模式或服务器级别设置是什么?是 SQL 2000(或兼容模式 80)吗?如果是这样,那么WITH选项将不会运行; SQL 2005 Mgmt Studio 生成的语法与 2005 兼容(即使您针对 SQL 2000 服务器或与 2000 兼容的数据库发出它)。

What's the compatibility mode or server level set to for the destination database? Is it SQL 2000 (or compatibility mode 80)? If so, then the WITH option will not run; the syntax generated by the SQL 2005 Mgmt Studio is 2005 compliant (even if you issue it against a SQL 2000 server or 2000-compliant database).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文