March 14, 2006 at 4:00 am
I am trying to use FOR XML EXPLICIT to group records that are related.
I want to achieve something like
I keep getting
The query looks something like
SELECT
1 AS Tag
, NULL AS Parent
, header AS 'Header!1!Id'
::
::
, NULL AS 'Child1!2!Child1Id'
, NULL AS 'Child1!2!Name'
, NULL AS 'Child2!3!Child1Id'
, NULL AS 'Child2!3!Name'
FROM
blah, blah, blah
UNION ALL
SELECT
1 AS Tag
, NULL AS Parent
, NULL AS 'Header!1!Id'
::
::
, ChildId AS 'Child1!2!Child1Id'
, Name AS 'Child1!2!Name'
, NULL AS 'Child2!3!Child1Id'
, NULL AS 'Child2!3!Name'
FROM
blah, blah, blah
UNION ALL
SELECT
1 AS Tag
, NULL AS Parent
, NULL AS 'Header!1!Id'
::
::
, NULL AS 'Child1!2!Child1Id'
, NULL AS 'Child1!2!Name'
, ChildId AS 'Child2!3!Child1Id'
, Name AS 'Child2!3!Name'
FROM
blah, blah, blah
Any help is gratefully appreciated.
Let me know if I am on the wrong path also, as I wouldn't be surprised
Thanks
Steve
March 14, 2006 at 8:25 am
You need to include an ORDER BY:
ORDER BY [Header!1!Id], [Child1!2!Child1Id], [Child2!3!Child2ID], [blah!blah!blahId]
-Eddie
Eddie Wuerch
MCM: SQL
March 14, 2006 at 1:09 pm
Excellent, so close yet so far.
Also, in my actual code I had not propogated the Header Id into the other parts of the union, it din't actually know what the relationships were.
And now BizTalk seems to like it.
Thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply