My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Sql To Xml ( Create xml using sql select )

Tuesday, 26 June 2012

Sql To XML Image



Example code for you
select * from (
select 1 as id,'one' as name
union all
select 2 as id,'two' as name
union all
select 3 as id,'three' as name) as a
for xml path('units'),ROOT('root')

Result XML
<root>
  <units>
    <id>1</id>
    <name>one</name>
  </units>
  <units>
    <id>2</id>
    <name>two</name>
  </units>
  <units>
    <id>3</id>
    <name>three</name>
  </units>
</root>

Explanation : Convert Sql Select To XML

The Keyword used to convert an sql select into xml is "for xml path(),ROOT()" the parameter which goes inside the path() eg. path('units')is the tag which wraps the every single record. And the parameter which goes inside the ROOT() eg.,ROOT('root')is the one one which forms the root xml tag, i.e it wraps all the records as a whole.






What is Sql Server

Monday, 4 June 2012

Sql Server is a database software to keep the information organised. Imagine it to a Giant excel software which can handle a very large where that data can be 1. Inserting to it and 2. Retrieved from it.
Sql Server is also called as Relational Database Management Systems as the data are organised in it using relations called Public Key and Foreign Key. SQL Server can be installed only in Windows Operating System.

The Sql Server Runs as a service in Windows and it can be accessed by a GUI tool called Sql Server Management Studio or Command Prompt.

 

Blogger news

Blogroll

Most Reading

8.6/10