Simply, my problem is that when I try to apply ":XML on" on the first of my query, I get a syntax error as in the below screenshot. I work on SQL Server 2012
The query and corresponding syntax error
The whole query is:
:XML ON
SET NOCOUNT ON
SELECT distinct 1 as Tag,
NULL as Parent,
NULL AS [ExamTypes!1],
NULL as [ExamType!2!ExamTypeID],
NULL as [Template!3!ShortString],
NULL as [Template!3!Order]
.
.
.
(sum code)
FOR XML EXPLICIT
Any help ?
It seems you may be running the query from SSMS. :FOR XML
is a SQLCMD command so you need to specify SQLCMD mode when the query is run from SSMS. This can be done from the query menu (Query-->SQLCMD Mode).