[翻译]  Stop SQL Server Management Studio from adding ANSI_NULLS and QUOTED_IDENTIFIER

[CHINESE]  阻止SQL Server Management Studio添加ANSI_NULLS和QUOTED_IDENTIFIER


How do I prevent SQL Management Studio (10.50.2500.0) from adding this to the beginning of every stored procedure when I right-click/Modify?

当我右键单击/修改时,如何阻止SQL Management Studio(10.50.2500.0)将其添加到每个存储过程的开头?

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

Neither of these settings are useful to me. ANSI_NULLS ON and QUOTED_IDENTIFIER ON is set on all my servers, DBs and connections I make. Besides that, I never use double quotes (I used brackets for reserved words) and all my nullable fields I properly use IS NULL when needed.

这些设置都不适合我。 ANSI_NULLS ON和QUOTED_IDENTIFIER ON在我的所有服务器,数据库和连接上设置。除此之外,我从不使用双引号(我使用括号作为保留字)和所有可空字段我在需要时正确使用IS NULL。

I delete the settings every time I edit a procedure. All my procedures properly have them set and that will never change in my environment. Verified by:

我每次编辑程序时都会删除这些设置。我的所有程序都已正确设置,并且在我的环境中永远不会改变。经核实:

SELECT uses_ansi_nulls, uses_quoted_identifier
FROM sys.sql_modules
WHERE object_id = object_id( 'proc_name' )

1 个解决方案

#1


7  

Not sure whether this counts as an answer or an unhelpful non-answer, but as Damien_The_Unbeliever suggested you absolutely don't want SSMS to stop scripting these lines. Because they are in the sql_modules table they form an integral part of the definition of the stored procedure, along with the SQL code itself. So they can't be "turned off" any more than your SQL code could.

不确定这是一个答案还是一个无用的答案,但正如Damien_The_Unbeliever建议你绝对不希望SSMS停止编写这些行的脚本。因为它们位于sql_modules表中,所以它们与SQL代码本身一起构成了存储过程定义的组成部分。因此,它们不能像SQL代码那样被“关闭”。

If you create/alter a stored procedure from a connection that has a different ANSI_NULLS option value to that used when the stored procedure was created/defined, then you change the behaviour of that stored procedure, permanently!

如果从具有与创建/定义存储过程时使用的ANSI_NULLS选项值不同的连接创建/更改存储过程,则永久更改该存储过程的行为!

It is for this reason that SSMS (and any half-decent SQL object scripting tool) will always output these lines - because if you remove them or change them, you are changing the definition of the stored procedure (removing them, particularly, is bad because it means that the behaviour of the stored procedure, depending on what connection it is published from, can vary).

正是由于这个原因,SSMS(以及任何一半体面的SQL对象脚本工具)将始终输出这些行 - 因为如果删除它们或更改它们,您将更改存储过程的定义(删除它们,特别是,不好)因为它意味着存储过程的行为,取决于它发布的连接,可能会有所不同)。

Doing a quick google search for "ANSI_NULLS QUOTED_IDENTIFIER stored procedure", the top result is the following article that seems to explain the options, and their impact, very clearly: http://ranjithk.com/2010/01/10/understanding-set-quoted_identifier-onoff/

快速谷歌搜索“ANSI_NULLS QUOTED_IDENTIFIER存储过程”,最高结果是下面的文章似乎解释了选项及其影响,非常清楚:http://ranjithk.com/2010/01/10/understanding-设置QUOTED_IDENTIFIER-ONOFF /


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号