创建/操作索引时的默认 SET 语句?

发布于 2024-11-04 13:48:06 字数 590 浏览 0 评论 0原文

有关 SET 语句的 MSDN 文档 包含以下内容段落:

在计算列或索引视图上创建和操作索引时,SET 选项 ARITHABORT、CONCAT_NULL_YIELDS_NULL、QUOTED_IDENTIFIER、ANSI_NULLS、ANSI_PADDING 和 ANSI_WARNINGS 必须设置为 ON。 NUMERIC_ROUNDABORT 选项必须设置为 OFF。

设置这些选项可以这样完成:

SET ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER, ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS ON
SET NUMERIC_ROUNDABORT OFF

我的问题是——有没有办法默认设置这些值,这样我们就不必在每次打开连接时手动设置它们?是系统范围内的,还是针对特定用户/登录的?这样做会有什么缺点吗?

MSDN's documentation on SET statements contains the following paragraph:

When you are creating and manipulating indexes on computed columns or indexed views, the SET options ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER, ANSI_NULLS, ANSI_PADDING, and ANSI_WARNINGS must be set to ON. The option NUMERIC_ROUNDABORT must be set to OFF.

Setting these options could be done like this:

SET ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER, ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS ON
SET NUMERIC_ROUNDABORT OFF

My question is -- is there any way to set these values by default, so that we don't have to set them manually every time we open a connection? Either system-wide, or perhaps for a specific user/login? And would there be any drawbacks to doing so?

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

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

发布评论

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

评论(3

小红帽 2024-11-11 13:48:06

它们已由 SSMS 设置。并通常受到客户的欢迎。我已经很长时间不需要明确设置这些了。

但是,如果需要,您可以使用 sp_configure 指定“用户选项"。

顺便说一句:我没有也不会设置这个。我建议您不要触摸和更改任何设置,除非您已经证明您需要这样做...

最终用户也不需要这些选项。仅 ALTER INDEX 和 CREATE INDEX(在此上下文中)语句需要它们,这些语句不是日常最终用户命令。

They are set by SSMS already. And by clients normally. I've not had to set these explicitly for a very long time.

However, if desired, you can use sp_configure to specify "user options".

BTW: I haven't and won't set this. I'd suggest you don't touch and change any setting unless you have proven you need to do so...

End users don't need these options either. They are only needed for ALTER INDEX and CREATE INDEX (in this context) statements which aren't day to day end user commands.

剧终人散尽 2024-11-11 13:48:06

尝试 sp_configure

我想这种方法的一个缺点是,如果有人更改稍后,您的脚本取决于脚本将破坏的特定集合。

Try sp_configure

I guess the one drawback of this approach is that if someone changes it later and your scripts depended on a certain set you scripts will break.

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