Stored Procedure Formatting in SQL 2019

Copper Contributor

I've stumbled across a very odd formatting issue, when it comes to creating a stored procedure in SQL Server 2019. The exact version we're using is:


Microsoft SQL Server 2019 (RTM-CU20) (KB5024276) - 15.0.4312.2 (X64) Apr 1 2023 12:10:46 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Standard 10.0 <X64> (Build 17763: ) (Hypervisor)


If I create a stored procedure, and then generate the ALTER script for it, all of the carriage returns in the

stored procedure disappear. The code in the stored procedure returned from the server is bunched up - it doesn't appear as I wrote it, at all.


I have never seen this behaviour before. 


Could this be an client issue, perhaps? I appear to be using SQL Server Management Studio 15.0.18424.0


Could there be a conflict between my client, and the server version?






2 Replies

@Chad_Allen Hi, I'd just like to add that, also, something seems to strip all comments from the stored procedure, also.


I have no idea whether this is caused by a setting in SQL Server Management Studio, or something else.

Could this be an client issue, perhaps?

@Chad_Allen , SQL Server engine don't modify any peace of your code, but SSMS as client/editor do, e.g. change a <Tab> into 4 spaces, see

Manage Code Formatting - SQL Server Management Studio (SSMS) | Microsoft Learn