I have a query:
DECLARE @str NVARCHAR(max)
SET @str = 'SET QUOTED_IDENTIFIER ON' + CHAR(13)+ CHAR(10) + 'GO' + CHAR(13) + CHAR(10) + 'Select 1 from MyTable'
PRINT @str
EXEC (@str)
It returns an error:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'GO'.
But if I exec the printed query in a new query editor it works fine.
I am using SQL Server 2014.