Why is SSMS altering my stored procedures (re-formatting, changing exec to EXECUTE, etc.)

余生长醉 提交于 2020-12-05 08:25:29

问题


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

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) = ''
 )

It will change that to:

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?

Thank you.


回答1:


This happens when you are working with Always Encrypted and have the option "Enable Parameterization for Alway Encrypted" enabled.

To fix:

  1. Go to: Query > Query Options > Execution > Advanced
  2. 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.



来源:https://stackoverflow.com/questions/48067013/why-is-ssms-altering-my-stored-procedures-re-formatting-changing-exec-to-execu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!