Results 1 to 2 of 2

Thread: FOR XML EXPLICIT Problem

  1. #1
    Join Date
    Dec 1969

    Default FOR XML EXPLICIT Problem

    Hi Everyone....i have this problem...i have a table with 3 columns<BR>First - Id_Folder<BR>Second - Folder<BR>Third - Id_Id_Folder<BR><BR>The third column has to be a number from the first column. As you can see im trying to do a hierarchy XML. i use this query<BR>SELECT<BR> 1 as Tag<BR> ,NULL as Parent<BR> ,A.Folder as [A!1!Folder]<BR> ,Folder as [B!2!Folder]<BR>FROM<BR> Folder_Gral as A<BR>WHERE <BR> A.Id_Id_Folder = 0 AND A.Id_Folder &#060;&#062; 0<BR><BR>UNION ALL<BR><BR>SELECT <BR> 2 as Tag<BR> ,1 as Parent<BR> ,A.Folder<BR> ,B.Folder<BR>FROM <BR> Folder_Gral as A, Folder_Gral as B<BR>WHERE<BR> B.Id_Id_Folder = A.Id_Folder<BR> AND A.Id_Folder &#060;&#062; 0<BR><BR>FOR XML EXPLICIT<BR><BR><BR>The thing is that altought it presents the folder name in their respective leves it doesn&#039;t respect the order , so all the second level folder apper as childs of the last parent folder listed and so on....<BR>So i hope somebody could point out my error or give a suggestion so i can make it work....<BR>Thanks for everything!<BR>Have a Nice Day!

  2. #2
    Join Date
    Dec 1969

    Default RE: FOR XML EXPLICIT Problem

    You have to specify an order by in the second select<BR><BR>ORDER BY ParentField, Child

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts