As described in the topic, Constructing XML Using FOR XML, RAW and AUTO mode do not provide much control over the shape of the XML generated from a query result. However, EXPLICIT mode provides the most flexibility in generating the XML you want from a query result.
The EXPLICIT mode query must be written in a specific way so that the additional information about the required XML, such as expected nesting in the XML, is explicitly specified as part of the query. Depending on the XML you request, writing EXPLICIT mode queries can be cumbersome. You may find that Using PATH Mode with nesting is a simpler alternative to writing EXPLICIT mode queries.
Because you describe the XML you want as part of the query in EXPLICIT mode, you must ensure that the generated XML is well formed and valid.
http://msdn2.microsoft.com/en-us/library/ms189068.aspx
SELECT
1 as Tag,
NULL as Parent,
BPJ.BPJ_ID as [ParentTable!1!BPJ_ID],
BPJ.BPJ_Bezeichnung as [ParentTable!1!BPJ_Bezeichnung],
NULL as [SubTable!2!BPP_ID!ELEMENT],
NULL as [SubTable!2!BPP_Datum!ELEMENT],
NULL as [SubTable!2!BPP_Ausgefuehrt!ELEMENTXSINIL],
NULL as [OtherTable!3!FNK_Funktion!ELEMENTXSINIL]
FROM
ParentTable BPJ
UNION ALL
SELECT
2 as Tag,
1 as Parent,
BPP.BPJ_ID,
NULL,
BPP_ID,
BPP_Datum,
BPP_Ausgefuehrt,
NULL
FROM
ParentTable BPJ
LEFT JOIN SubTable BPP ON BPJ.BPJ_ID = BPP.BPJ_ID
WHERE BPP_Datum IS NOT NULL
UNION ALL
SELECT
3 as Tag,
2 as Parent,
BPP.BPJ_ID,
NULL,
BPP_ID,
NULL,
NULL,
CTI_Bez
FROM
SubTable BPP
LEFT JOIN CodeInhaltCodeTypView CTV ON CTV.CTI_ID = BPP.CTI_FunktionsCode
WHERE BPP_Datum IS NOT NULL
ORDER BY [ParentTable!1!BPJ_ID], [SubTable!2!BPP_ID!ELEMENT], Tag, Parent, [SubTable!2!BPP_Datum!ELEMENT]
FOR XML EXPLICIT, ROOT ('ParentTable')