Semicolon in T-SQL

  • Is it considered good practice to end your T-SQL statements with a semicolon?

    SELECT *

    FROM Practice;

  • I would say no. I never write semicolon into TSQL. It is neither good or bad.

  • Check the below article for more info on it.

    The GO Command and the Semicolon Terminator[/url]

    -----------------------------------------------------------[font=Arial Black]Time Is Money[/font][font=Arial Narrow]Calculating the Number of Business Hours Passed since a Point of Time[/url][/font][font=Arial Narrow]Calculating the Number of Business Hours Passed Between Two Points of Time[/font]

  • I'd say it's a good habit to get into. If you use CTE's you must use a semi-colon terminator on the statement preceding the CTE. Microsoft has said they're going to be introducing more functionality that requires it.

    Start using it now. It doesn't cost anything. It will help with the CTE. It will line you up for future functionality without rewrites.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I thought I read somewhere that the ';' was the ANSI standard statement delimiter and that it was soon going to be required in SQL Server. Maybe not this version or the next, but that it was coming.

  • Yeah, maybe that's what I read too. I know I saw that it's going to more and more standard, if not required. So I'm working it into my code now. Might as well develop good habits now.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply