XML is the new data type introduced in SQL Server 2005. XML stands for Extended Markup langugage. A world wide accepted standard to pass the data through network. I can remember my experience on using XML data in legacy systems of SQL server, we used to store those data in the form of varchar data types. But, with the introduction of sql server 2005 XML data type, we can store the data in the form of XMLs.
Let create a table Venkattable,
create table Venkattable(id int, Name varchar(10),age int)
Am inserting some data into this table,
insert into Venkattable values(1,'Venkat',16)
insert into Venkattable values(2,'Arun',16)
insert into Venkattable values(3,'Suba',16)
insert into Venkattable values(4,'Karthi',16)
insert into Venkattable(id,age) values(4,16)
select * from Venkattable
XML Raw:
XML raw statement is used to display your result set in the form of XML but the format of display is quite intersting.It will show up the row by row data with a tag "Row"
Let see a sample for the XML RAW, am trying to display the result set in XML RAW mode.
SELECT * FROM Venkattable FOR XML RAW
The output resembles,

Below is the syntax to acheieve the same.
SELECT * FROM Venkattable FOR XML RAW, ELEMENTS
The output resembles as below,

In the XML RAW method, we lose the identity about the table VenkatTable. Suppose, we need to fetch the table identity in our XML output. We can use XML AUTO method.
The syntax for XML Auto is,
SELECT * FROM Venkattable FOR XML AUTO
The output resembles as below,

Regards,
Venkatesan Prabu .J
1 comment:
This feature is already available in SQL Server 2000. But mentioned as a new feature in SQL Server 2005
Post a Comment