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)
 For XML explicit single table

Author  Topic 

John Sourcer
Yak Posting Veteran

91 Posts

Posted - 2009-02-16 : 08:28:56
Hi All,

Is it possible to do a FOR XML EXPLICIT query on a single table?

I have a table:

ID | ParentID | Name
1 | 0 | Bob
2 | 1 | James

And I am trying to return this as nested XML. I know I can do this if I know how many levels it has, but I don't.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-16 : 08:54:22
have a look at common table expressions

http://msdn.microsoft.com/en-us/library/ms186243.aspx
Go to Top of Page

John Sourcer
Yak Posting Veteran

91 Posts

Posted - 2009-02-16 : 08:56:34
Thanks as always oh great Yak.

I'm using CTE's elsewhere for trees. Just didn't know if you could return the data FOR XML
Go to Top of Page
   

- Advertisement -