.But starting statements with terminators teaches bad habits .For example I had a dev recently who scattered ; randomly until the SQL proc started working .Once it had been explained that the ; is a terminator just like in C# he put them correctly and asked me "Then why do people put them at the beginning of statements? That's just stupid." (.His words) .He'd read up on CTEs online and concluded ,based on some people putting the ; at the end and others at the beginning ,that it wasn't a statement terminator ,that it was just some command that no one explained what it did and that followed rules for placing that no one explained
?How about we just teach people correctly instead
Eirikur Eiriksson (3/30/2015)
;With due respect, additional and extra semicolons between statements will not cause any problems and CTE statements will run, without the semicolon it will not.
.Without ; C# code won't work .We don't see samples of C# code starting with statement terminators
;WITH makes sense to anyone who has been around a while, but without an explanation those newer to t-SQL (i.e. "accidental dba's") pick it up as "standard practice". By the time they figure it out, much code has been written and it isn't likely to get changed. I'd much prefer to see example code akin to:
-- a CTE must either be the first statement in a batch, or the previous statement must be terminated with a semi-colon or an END
Ultimately, the responsibility for teaching good practices falls on those who know good practices.