简体   繁体   English

我应该在SQL Server 2014中设置ARITHABORT

[英]Should I set ARITHABORT in SQL Server 2014

I am looking at some code that was written a while ago, in the database helper before a stored procedure is called they set ARITHABORT ON . 我正在查看一段时间之前编写的一些代码,在调用存储过程之前,在数据库帮助器中将它们设置为ARITHABORT ON

From my understanding this is not needed for versions of SQL Server later than 2005, if the ANSI_Warnings is ON. 根据我的理解,如果ANSI_Warnings为ON,那么对于晚于2005的SQL Server版本,则不需要这样做。

Do I still need to set this ? 我还需要设置吗? Does it provide a performance benefit? 它是否提供了性能优势?

Edit 1 : According to this article I do not need to set it, but I can not find another definite answer on this. 编辑1:根据这篇文章我不需要设置它,但我找不到另一个明确的答案。

If you look at SET ARITHABORT , setting ANSI_WARNINGS to ON will automatically set ARITHABORT to ON as well with a compatibility level at 90 or higher (SQL Server 2005 or above): 如果查看SET ARITHABORT ,将ANSI_WARNINGS设置为ON将自动将ARITHABORT设置为ON,兼容级别为90或更高(SQL Server 2005或更高版本):

Setting ANSI_WARNINGS to ON implicitly sets ARITHABORT to ON when the database compatibility level is set to 90 or higher. 当数据库兼容级别设置为90或更高时,将ANSI_WARNINGS设置为ON会将ARITHABORT隐式设置为ON。 If the database compatibility level is set to 80 or earlier, the ARITHABORT option must be explicitly set to ON. 如果数据库兼容级别设置为80或更早,则必须将ARITHABORT选项显式设置为ON。

With compatibility level 80 you have to manually set it. 兼容级别80,您必须手动设置它。

This is also possible that your software set it to off when it opens a connection and the only solution was to add it to the procedure. 这也可能是您的软件在打开连接时将其设置为关闭,唯一的解决方案是将其添加到过程中。

After upgrading to compatibility level 90 or higher, you should run: 升级到兼容级别90或更高级别后,您应该运行:

DBCC FREEPROCCACHE

If will remove execution plan and recompile procedures. 如果将删除执行计划并重新编译过程。

It can be good to also run both commands before new plans get created: 在创建新计划之前,还可以运行这两个命令:

DBCC UPDATEUSAGE(db_name);
EXEC sp_updatestats;

I assume this database might be old (SQL Server 2000 or earlier) and it may be good to run this as well: 我假设这个数据库可能是旧的(SQL Server 2000或更早版本),也可以运行它:

DBCC CHECKDB WITH DATA_PURITY;

DBCC CHECKDB will check the DB and its data(types) used and make sure everything is fine with your new version and compatibility level. DBCC CHECKDB将检查数据库及其使用的数据(类型),并确保新版本和兼容级别一切正常。

In our database we had some SPs running much faster with this, even on later SQL Servers. 在我们的数据库中,我们有一些SP运行更快,即使在后来的SQL Server上也是如此。

This occurs, if your database is older and was pushed through times with upgrade scripts. 如果您的数据库较旧并且使用升级脚本推迟了数据,则会发生这种情况。 In former days the default was not "ON" and therefore older databases might still work with a bad default. 在过去,默认设置不是“开启”,因此较旧的数据库可能仍然使用错误的默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM