Geeks With Blogs
Łukasz Kuryło's blog

I just wanted to return from sql server data as xml. This is very easy to do, because sql server has a build-in suppot for that.

select Id, Name from Extensions FOR XML RAW('Extension'), ROOT('Extensions')

But using this query, the returned column has name like XML_F52E2B61-18A1-11d1-B105-00805F49916B

It's been some time when I manually created a sql query, so I lost few minutes to think, how to alias this column using the AS keyword.

Correct query looks as follows

select (select Id,Name  from Extensions  FOR XML RAW('Extension') , ROOT('Extensions')) as alias


I see I just need to remember some basics about sql/tsql.. Too much NHibernate I see.

Posted on Tuesday, August 23, 2011 5:57 PM SQL | Back to top

Comments on this post: Aliasing the data returned as xml

Comments are closed.
Comments have been closed on this topic.
Copyright © Łukasz Kuryło | Powered by: