I face an issue while trying to generate a XML Instance in SSMS, Im using 3 views to generate a xml file, here is the code I wrote:
DECLARE @xmlDoc xml
SET @xmlDoc = (
SELECT *
FROM db.View1 AS v1
INNER JOIN db.View2 AS v2 ON v2.link = v1.link
INNER JOIN db.View3 AS v3 ON v3.link = v1.link
FOR XML AUTO)
SELECT @xmlDoc
What I get is in this format:
<v1 field="data" ...>
<v2 field="data" ...>
<v3 field="data" .../>
</v2>
</v1>
But I need to have v2 and v3 at the same level of imbrication, like this :
<v1 field="data" ...>
<v2 field="data" .../>
<v3 field="data" .../>
</v1>
If someone have any idea, It will help me a lot ! Thanks !