• Koen Verbeeck (2/14/2012)


    kll 51891 (2/14/2012)


    I would have expected it to fail due to no newline or semicolon.<snip>

    The semicolon is not yet obligated, except when using the WITH clause. This probably will change in a future version.

    If there's a statement before the WITH clause, it should be terminated with a semicolon. Pay attention, this is not the same as saying that it should be ";WITH". If everyone starts terminating statements with semicolon in old code to make the code portable to a newer edition of SQL Server, all ;WITH statements will fail.

    Thank you for the clarification.

    A quick test:

    use master

    select top 10 * from sys.all_columns

    select top 10 * from sys.all_objects

    select top 10 * from sys.all_columns select top 10 * from sys.all_objects

    select top 10 * from sys.all_columns ;; select top 10 * from sys.all_objects

    reveals that you are correct in the missing semicolons are OK. But it doesn't show why an abundance of semicolons should have detrimental effects.

    My quoting of ";with" were somewhat tongue-in-cheek as it is the first keyword that I am aware of that doesn't accept a newline as a break in command.

    Anyway, looking objectively at stuff, then the fact that I can write

    Select *

    From xx

    Where something is right

    should warn me that semicolons were problably superflous.