Usage of Semicolons in SQL Server

As you know, semicolon is used as a statement terminator in almost all RDBMSs. However the usage of semicolon is optional in SQL Server except a few cases. Here are atleast the three cases where usage of semicolon is a must

1 At the start of the Common Table Expression (If any statement preceeds it)

2 If the procedure name is GO ,to execute it use at the end of GO (ex EXEC GO; as shown in Fun with GO)

3 At the end of Merge statement

Published 10 November 2009 09:37 by Madhivanan
Filed under: , ,

Comments

# re: Usage of Semicolons in SQL Server

10 November 2009 11:09 by Dave Ballantyne

Point 1 is not strictly true.

It is required at the end of a statement preceding the CTE.

# re: Usage of Semicolons in SQL Server

10 November 2009 12:44 by Madhivanan

Dave Ballantyne , you are right