Search code examples
sql-servervisual-studiot-sqlsql-server-data-tools

Can I write comments in TSQL files that won't end up being published?


I'm using a code generator of my own to produce T-SQL code, using some criterias. I want the output code to show what criterias were used to produce the code, but I'd like to keep that information from being deployed to the server.

Here's an example:

CREATE PROC blabla
AS
BEGIN

    /*
    This code is the result of calling code generator X with the following criterias:

    Variable1 = 'My first variable value'
    Variable2 = 'My second variable value'
    */

    (Actual T-SQL code)

END

Basically, I want to know if a special syntax exists inside SSDT to delimit a non compilable text segment. Not looking for pure TSQL syntax here!

Does it exists?

An additional note: I'm aware that I can use TSQL comment removal tools but I'm looking for a more proactive solution here.


Solution

  • You can keep the comments outside of the stored procedures and separate it from create procedure with GO:

    /* A comment about the criteria used...*/
    go
    create procedure a
    as
    begin
      declare @i int
    end
    go
    

    This way the stored procedure will not include your comments, as it would be created in a separate batch.