1. Help : 6833 error with for xml explicit
Hi all
I am getting the error below.
Server: Msg 6833, Level 16, State 1, Line 1
Parent tag ID 5 is not among the open tags. FOR XML EXPLICIT requires parent tags to be opened first. Check the ordering of the result set.
The only info I have been able to find on the web suggests that this error occurs if the ordering of the query is wrong or if a null is used in a subquery on a field used to join tables in that subquery. I dont have this circumstance with my code however and the ordering appears to me to be correct.
Heres my code:
select distinct
1 as Tag,
0 as Parent,
Item.fldLabel as [Item!1!fldLabel],
null as [Menu!2!fldLabel],
null as [Item!3!fldLabel],
null as [Menu!4!fldLabel],
null as [Item!5!fldLabel],
null as [Menu!6!fldLabel]
from
DiagOk as Item
where
Item.fldTierId = 1
union
all
select distinct
2 as Tag,
1 as Parent,
null,
Menu.fldLabel as [Menu!2!fldLabel],
null,
null,
null,
null
from
DiagOk as h1,
DiagOk as Menu
where
h1.fldTierId = 1
and
h1.fldId = Menu.fldId
union
all
select distinct
3 as Tag,
2 as Parent,
null,
null,
Item.fldLabel as [Item!3!fldLabel],
null,
null,
null
from
DiagOk as Item,
DiagOk as h1
where
Item.fldTierId = 2
and
h1.fldId = Item.fldParentId
union
all
select distinct
4 as Tag,
3 as Parent,
null,
null,
null,
Menu.fldLabel as [Menu!4!fldLabel],
null,
null
from
DiagOk as h1,
DiagOk as Menu
where
h1.fldTierId = 2
and
h1.fldId = Menu.fldId
union
all
select distinct
5 as Tag,
4 as Parent,
null as [Item!1!fldLabel],
null as [Menu!2!fldLabel],
null as [Item!3!fldLabel],
null as [Menu!4!fldLabel],
Item.fldLabel as [Item!5!fldLabel],
null as [Menu!6!fldLabel]
from
DiagOk as Item,
DiagOk as h1
where
Item.fldTierId = 3
and
h1.fldId = Item.fldParentId
union
all
select distinct
6 as Tag,
5 as Parent,
null as [Item!1!fldLabel],
null as [Menu!2!fldLabel],
null as [Item!3!fldLabel],
null as [Menu!4!fldLabel],
null as [Item!5!fldLabel],
Menu.fldLabel as [Menu!6!fldLabel]
from
DiagOk as h1,
DiagOk as Menu
where
h1.fldTierId = 3
and
h1.fldId = Menu.fldId
order by
[Item!1!fldLabel],
[Menu!2!fldLabel],
[Item!3!fldLabel],
[Menu!4!fldLabel],
[Item!5!fldLabel],
[Menu!6!fldLabel]
for
xml explicit
2. ORACLE 6.0 Questions
3. Generating Schema compliant XML from SQL Server Database using SQLXML and XML Explicit -- [Performance/Maintenance issues]
4. How To Change server and Database for DataEnv Connection
5. SQL XML Stored Procedure using XML Explicit Returing XML to ASP Page
6. Installing IDSmail activex on users machine
7. Q: Hiding/not showing a column in the resulting xml using xml explicit
8. how do you open a database through tcp/ip preferably dsn-less?
9. problem in creating XML using For XML explicit
10. Facing problem in creating XML using FOR XML EXPLICIT
11. SQL Server 2K, XML/XSL for Explicit problem with passing XML paramters values
12. 6833 error message
13. Broken XML when running queries with FOR XML AUTO and FOR XML EXPLICIT