SQL for Smarties | SQL Programming Style | Trees and Hierarchies in SQL | SQL Puzzles and Answers | Data and Databases


Wednesday, August 30, 2006

Semicolon - Why?

SQL Apprentice Question
Why does a semicolon appear at the end of some T-SQL statements in 2005 BOL?

It doesn't seem necessary.


Celko Answers
The semi-colon is part of Standard SQL and always has been. In the
early days of Sybase/SQL Server T-SQL, you did not need it because of
the syntax of the language. Back then, it was just good programming
practice to make the code portable and readable. Today, it is required
in some parts of the language.

It is a statement terminator, not a separator or an introducer -- very
important, if you ever worked with HP's MPE operating system which had
sub-systems that used the semi-colon all three ways.

No comments: