Comments NOT ignored by CREATE PROCEDURE | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Comments NOT ignored by CREATE PROCEDURE

USE Northwind
–[1] How SQL2K know to put this comment on top of the SP? —-
PRINT ‘123’ Question:
Executed with Query Analyzer, the Stored Proc got created with the comment line (–[1] etc. ) on top of it. I am puzzled as usually QA ignores comments. How come this time it decides to consider comments (– or /* block */) as significant data and integrate those comments in the source of the Stored Proc? Probably it is a good "side-effects" as many of our SPs have a comment block before the CREATE PROC. I would like to know why SQL2K treats comments differently with CREATE PROC. Thanks in advance.
Try inserting GO after a script comment that you don’t want included in the object definition.
Adding GO after the comments and before the CREATE PROC will indeed remove the comment line from the SP source. I was just wondering if the inclusion of the comments before the CREATE PROC was something Query Analyzer does behind the scene or standard from SQL2K behaviour. In our team, some developers put the comments block after CREATE PROC like that: CREATE PROCEDURE myProc
@Param1 …,
@Param2 …
comments & doc
*/ FYI, when creating a Stored Proc from within Visual Studio 2003, the template of the empty SP also follows the same pattern than above (comments block after the CREATE PROC statement).