Bug - Semicolons added to GO if GO followed by CTE (WITH)
alicorn68
Posts: 9 Bronze 1
SQL Prompt: 9.0.9.3951 (latest as of this writing)
Simplest reproducible I was able to come up with (entirety of the script):
SELECT a=1;
GO
WITH base AS (SELECT b=1) SELECT * FROM base o;
-- Result:
SELECT a=1;
GO; -- <<== ADDS INVALID SEM-COLON
WITH base AS (SELECT b=1) SELECT * FROM base o;
-- NOTE: Issue does not occur if the WITH has a semicolon immediately preceding. But this is just bad SQL:
SELECT a=1;
GO -- <<== WILL NOT ADD SEMICOLON
;WITH base AS (SELECT b=1) SELECT * FROM base o;
-- OR
SELECT a=1;
GO -- <<== WILL NOT ADD SEMICOLON
;
WITH base AS (SELECT b=1) SELECT * FROM base o;
EDIT: remove square brackets to not force forum into bbcode
Simplest reproducible I was able to come up with (entirety of the script):
SELECT a=1;
GO
WITH base AS (SELECT b=1) SELECT * FROM base o;
-- Result:
SELECT a=1;
GO; -- <<== ADDS INVALID SEM-COLON
WITH base AS (SELECT b=1) SELECT * FROM base o;
-- NOTE: Issue does not occur if the WITH has a semicolon immediately preceding. But this is just bad SQL:
SELECT a=1;
GO -- <<== WILL NOT ADD SEMICOLON
;WITH base AS (SELECT b=1) SELECT * FROM base o;
-- OR
SELECT a=1;
GO -- <<== WILL NOT ADD SEMICOLON
;
WITH base AS (SELECT b=1) SELECT * FROM base o;
EDIT: remove square brackets to not force forum into bbcode
Tagged:
Answers
If it helps I have attached one of the styles tested. All styles seem to have the same issue.
Note: This issue is not shown (does not occur) when editing the style and using "Preview current query"
This looks like a question that one of Support engineers will need to investigate for you.
If you've a got support contract, please send us a ticket. Provide as much information as you can - screenshots of any errors, log files etc – so we can help you as fast as possible.
If you're not covered by a Support contract at the moment, email our Sales team at sales@red-gate.com, and they'll be able to help.
Redgate Software