• Hardy21 (12/23/2010)


    @carlo: you are right.

    But as per the question, we should give answer for the question: What will you get executing this T-SQL code in Query Analizer (SQL2K) or Management Studio (2005)?

    So, EXEC(@sql) result is 1,2,3,4.

    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)