• Carlo Romagnano (12/23/2010)

    If you get 1,2,3,4

    that means that in the script you do not report single line comments.

    The script in @sql looks like this:

    PRINT 2 is joined to the upper line.

    set @sql =

    'print 1

    -- Comment one print 2

    -- Comment two

    print 3

    -- Comment three

    print 4

    '

    exec (@sql)

    That is not what you see in SQL Query Analzer. The output actually is

    What you see...

    -----------------------

    print 1

    -- Comment one

    print 2

    -- Comment two

    print 3

    -- Comment three

    print 4

    is not what you get!

    -----------------------

    1

    3

    4