From time to time I see SQL Server statements that start with semicolon ';' like below
;WITH cte
AS (SELECT ROW_NUMBER() OVER (PARTITION BY Col1, Col2, Col3
ORDER BY ( SELECT 0)) RN
FROM #MyTable)
DELETE FROM cte
WHERE RN > 1
The other example is ;THROW
Why exactly there is a ';' the beginning of TSQL statements
Update 1:
Please note that I am asking about ';' at the beginning of statements. This question is not duplicate of this one
When should I use semicolons in SQL Server?
Update 2:
@MartinSmith answer makes sense.
Just to make sure we have a complete answer for this post, consider this respected article:
http://www.sommarskog.se/error_handling/Part1.html#jumpTHROW
At this point you might be saying to yourself: he must be pulling my legs, did Microsoft really call the command ;THROW? Isn't it just THROW? True, if you look it up in Books Online, there is no leading semicolon. But the semicolon must be there. Officially, it is a terminator for the previous statement, but it is optional, and far from everyone uses semicolons to terminate their T‑SQL statements.
I agree with @MartinSmith answer, but it seems that the matter is being taken to some quite extreme levels.
Typically, in a stored procedure THROW is a statement by its own line. SQL developers simply don't just merge SQL lines like that and miss a semicolon.
To me, there is more chance people accidently drop a table than mixing 'THROW' statement with another line of TSQL
Is the case explained in the quote above something extreme and rare to happen? or I am missing a point here?