BUG: Semi-Colon after GO followed by WITH
alicorn68
Posts: 9 Bronze 1
in SQL Prompt
Test code:
USE [master]; GO; -- ISSUE IS HERE WITH [test] AS (SELECT [a]=1) SELECT * FROM [test] [t];</code>USE [master] GO WITH [test] AS (SELECT [a]=1) SELECT * FROM [test] [t]</pre></div><div>After using menu "SQL Prompt->Insert Semicolons" that becomes:<br><div><pre class="CodeBlock"><code>
Yes, the statement before a WITH needs to be terminated with a semi-colon. But not the GO.
Please fix this long standing bug.
Please fix this long standing bug.
Tagged:
Best Answer
-
Alex B Posts: 1,157 Diamond 4Hi @alicorn68,
This has been fixed in 9.4.12 in that it no longer adds a semicolon after the GO to make the statement invalid. However it now does not insert the semicolon before the WITH statement at all.
So this:<div>USE [master] <span style="background-color: transparent; color: inherit; font-size: inherit; font-family: roboto, "helvetica neue", Arial, sans-serif;">GO </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: roboto, "helvetica neue", Arial, sans-serif;">WITH [test] AS (SELECT [a]=1) SELECT * FROM [test] [t]</span></div>
becomes:<div>USE [master]; <span style="background-color: transparent; color: inherit; font-size: inherit; font-family: roboto, "helvetica neue", Arial, sans-serif;">GO </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: roboto, "helvetica neue", Arial, sans-serif;">WITH [test] AS (SELECT [a]=1) SELECT * FROM [test] [t];</span></div>
When inserting the semicolon only.Kind regards,
Alex
Answers
Ah, righto I see what you mean - if you only add the semicolons it puts the semicolon after the GO.
If you format the query (ctrl+k, ctrl+y) it will actually place things correctly:
becomes
I've raised this with the team so that they are aware.
Kind regards,
Alex
Have you visited our Help Center?
USE [master]
GO
WITH [test] AS (SELECT [a]=1) SELECT * FROM [test] [t]
but it will for the following script
USE [master]
GO --
WITH [test] AS (SELECT [a]=1) SELECT * FROM [test] [t]
I see what you mean, your second entry becomes:
In either case, it no longer breaks the script, but it's good to know this behavior!
Kind regards,
Alex
Have you visited our Help Center?