The FOR XML and FOR JSON clauses are invalid in views, inline functions, derived tables, and subqueries when they contain a set operator. To work around, wrap the SELECT containing a set operator using derived table or common table expression or view and apply FOR XML or FOR JSON on top of it. - cSharp Coder

Latest

cSharp Coder

Sharp Future

Wednesday, July 29, 2020

The FOR XML and FOR JSON clauses are invalid in views, inline functions, derived tables, and subqueries when they contain a set operator. To work around, wrap the SELECT containing a set operator using derived table or common table expression or view and apply FOR XML or FOR JSON on top of it.

There's a simple workaround for that, you should wrap your union query(or any derived table for that matter) with another select. Do this and then continue the syntax normally:
select * from
(
SELECT 1 as I
UNION ALL
SELECT 2 as J
) as K
Pls Mark as a answer

No comments:

Post a Comment