What is the meaning of ; at the end of queries?
For example; what is the difference between:
select 1
select 2
and
select 1;
select 2
What is the meaning of ; at the end of queries?
For example; what is the difference between:
select 1
select 2
and
select 1;
select 2
"From a SQLServerCentral.Com article by Ken Powers:
The Semicolon
The semicolon character is a statement terminator. It is a part of the ANSI SQL-92 standard, but was never used within Transact-SQL. Indeed, it was possible to code T-SQL for years without ever encountering a semicolon.
Usage
There are two situations in which you must use the semicolon. The first situation is where you use a Common Table Expression (CTE), and the CTE is not the first statement in the batch. The second is where you issue a Service Broker statement and the Service Broker statement is not the first statement in the batch."
this is from When should I use semicolons in SQL Server? which might be what you are looking for
which is in turn "straight a cut and paste"
I think this might be stack overflows version of a joke.
edit: ; are also after merge statements
Using the ; is the correct way to end one statement and start another. If you do not use the ; you may get unexpected results
Giving a list of situation that are 'required' is always prone to omission. There are other situations besides commont table expression and SSB which the parser cannot handle w/o semicolon terminating the previous statement, like THROW
or WITH XMLNAMESPACES and the list is bound to grow.
The correct answer is: semicolon terminators are required and should always be put whenever writing new code. Period. Omitting them is tolerated, but is on the official deprecation list:
Deprecated feature: Transact-SQL Not ending Transact-SQL statements with a semicolon
Replacement: End Transact-SQL statements with a semicolon ( ; ).
Ignoring this deprecation warning is on your own peril.