Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 XML question

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2008-06-20 : 19:13:02
Hi there

I have a problem I have tried to solve using FOR XML PATH, EXPLICIT and all. The problem I am having is that when trying to produce the xml the root node has 'task' as tag identifier <task id="1" ...> I guess you could call it, but I also want the child elements to have 'task' as their tag <task id="2" ...> . how can I go about getting that since I cannot name two views I am selecting from with same alias....

Thanks!
SELECT EquipmentID + 1 as id,
EquipmentDescr as [name],
'#99ccff' AS color,
'true' AS [expand],
(SELECT JobID + 2 AS id,
'Layout#' AS [name],
'#99ccff' AS color,
(SELECT [taskproperty-id] AS [taskproperty-id],
[value] AS [value]
FROM dbo.VXmlGanttBody customproperty
WHERE customproperty.JobID = task2.JobID
FOR XML AUTO, TYPE)
FROM VJobs task2
WHERE task2.EquipmentID = task.EquipmentID
FOR XML AUTO, TYPE )
FROM VEquipments task
ORDER BY EquipmentDescr
FOR XML AUTO, TYPE

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2008-06-21 : 03:33:37
TRY CHANGING FOR XML AUTO, TYPE WITH THE BELOW ONE

FOR XML AUTO, TYPE, ROOT('ROOT')
Go to Top of Page
   

- Advertisement -