Sample Header Ad - 728x90

When creating stored procedure, are the comments before the definition always preserved?

6 votes
1 answer
823 views
When I wrote some comments before the CREATE PROCEDURE command, those comments seem to be preserved as part of procedure definition. For example, when I create procedure like this
/*Comment header*/
CREATE OR ALTER PROCEDURE example_procedure
AS 
SELECT 1 AS Id
The /*Comment header*/ is stored as part of definition. [Fiddle](https://dbfiddle.uk/-CaBLVX6) Is that documented behavior, can I always count on that? Or is that just some unreliable SQL Server quirk? My naive understanding is that the procedure definition starts with CREATE keyword, so I am hesitant to rely on behavior that goes against my intuition.
Asked by Yano_of_Queenscastle (1998 rep)
Jan 29, 2025, 07:45 AM
Last activity: Jan 30, 2025, 12:00 PM