为什么SSMS会更改我的存储过程(重新格式化,将exec更改为EXECUTE等) [英] Why is SSMS altering my stored procedures (re-formatting, changing exec to EXECUTE, etc.)
问题描述
SSMS突然重新格式化了存储过程-以前从未这样做过.这是我在说的一个例子.这是我上周创建的存储过程的开始:
SSMS is suddenly re-formatting my stored procedure - it has never done this before. Here's an example of what I'm talking about. Here's the start of the stored procedure I created last week:
CREATE PROCEDURE [dbo].[usp_LoanDataNames]
(
@LoanID varchar(max) = null,
@Columns varchar(max) = null,
@DataNames NVARCHAR(MAX) = '',
@SQL NVARCHAR(MAX) = ''
)
AS
我今天之前创建的所有存储过程仍然具有该格式.但是,当我今天以与上述相同的格式创建一个新的存储过程,然后拉出存储过程脚本时,它看起来像这样:
All the stored procedures I created before today still have that format. But when I create a new stored procedure today, with the same exact format as above, and then pull up the stored procedure script, it looks like this:
CREATE PROCEDURE [dbo].[usp_LoanDataNames2]
@LoanID VARCHAR (MAX)=NULL, @Columns VARCHAR (MAX)=NULL, @DataNames NVARCHAR (MAX)='', @SQL NVARCHAR (MAX)=''
AS
这是与以前不同的格式.它将所有参数上移,以立即跟随存储过程的名称,并将它们全部放在同一行上.另外(我也不必费心发布整个存储过程,所以我也没有发布此部分),它将 Exec
更改为 Execute
.并且它改变了各行上的缩进,并将许多小写单词改为大写.
This is a different format than before. It moved all the parameters up to immediately follow the stored procedure name, and put them all on the same line. Also (and I didn't bother posting the entire stored procedure so I didn't post this part), it changes Exec
to Execute
. And it changes the indenting on various lines, and changes many lowercase words to uppercase.
如果我这样做,它甚至会更改格式:
It even will change the formatting if I do it this way:
CREATE PROCEDURE [dbo].[usp_LoanDataNames]
AS
DECLARE
@LoanID varchar(max) = null,
@Columns varchar(max) = null,
@DataNames NVARCHAR(MAX) = '',
@SQL NVARCHAR(MAX) = ''
)
它将更改为:
CREATE PROCEDURE [dbo].[usp_LoanDataNames2]
@LoanID VARCHAR (MAX)=NULL, @Columns VARCHAR (MAX)=NULL, @DataNames NVARCHAR (MAX)='', @SQL NVARCHAR (MAX)=''
AS
知道为什么会这样吗?我们在这里使用某些标准,并且原始存储过程正在格式化我的公司喜欢的格式.问题是我不能再使用该格式,因为我创建或更改的每个存储过程现在都会自动重新格式化.有什么想法吗?
Any idea why this is happening? We have certain standards we use here, and the original stored procedure is formatting my company prefers. The problem is I CAN'T use that formatting anymore, because every single stored procedure I create or alter automatically re-formats now. Any ideas?
谢谢.
推荐答案
当您使用始终加密"并启用选项为始终加密启用参数化"时,会发生这种情况.
This happens when you are working with Always Encrypted and have the option "Enable Parameterization for Alway Encrypted" enabled.
要解决:
- 转到:
Query>查询选项>执行>高级
- 取消选中
启用始终加密的参数化
(位于列表末尾)
- Go to:
Query > Query Options > Execution > Advanced
- un-check
Enable Parameterization for Alway Encrypted
(its at the end of the list)
只有在处理临时查询和非存储过程时,才应启用此选项.
You should only have this option enabled when you are working with ad-hoc queries and not stored procedures.
这篇关于为什么SSMS会更改我的存储过程(重新格式化,将exec更改为EXECUTE等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!