SQL에서 XML 출력을 생성하려고하는데 UNION 문을 사용해야하고 출력 열의 이름을 지정해야합니다.XML UNION FOR XML 이름 출력 열
내가 사용하여 UNION 문을 사용하지 않았을 때 전에이 작업했다 : XmlOutput로 출력 XML 열 이름
는select(
SELECT
[CompanyName],
[Address1],
[Address2],
[Address3],
[Town],
[County],
[Postcode],
[Tel],
[Fax],
[Email],
[LocMap]
FROM [UserAccs] FOR XML PATH ('AccountDetails'), root ('Root')
) as XmlOutput
지금 노력하고
:
select(
SELECT
[CompanyName],
[Address1],
[Address2],
[Address3],
[Town],
[County],
[Postcode],
[Tel],
[Fax],
[Email],
[LocMap]
FROM [UserAccs]
UNION
SELECT
[CompanyName],
[Address1],
[Address2],
[Address3],
[Town],
[County],
[Postcode],
[Tel],
[Fax],
[Email],
[LocMap]
FROM [UserAppAccs]
FOR XML PATH ('AccountDetails'), root ('Root')
) as XmlOutput
을
오류 메시지가 표시됩니다.이 문제를 해결하는 방법을 알고 있습니까?
The FOR XML clause is 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 syntax and apply FOR XML on top of it.
감사 J.
오류 메시지가 무엇을 말합니까? – Mithrandir
위의 오류 메시지 ... 감사합니다. – JBoom