XML Using SQL server 2008

Posted by Man2vb under Sql Server on 5/10/2010 | Views : 4060 | Status : [Member] | Replies : 3
Please any one tell me, how to generate following XML using FOR XML in SQL server 2008,
There is three columns First_Name, Middle_Name and Last_Name and I want to select all data of thease column using /Row/Cell/Data tags. I am waiting for your reply :)

<?xml version="1.0" encoding="utf-16"?>
<ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<ss:Styles>
<ss:Style ss:ID="1">
<ss:Alignment ss:Horizontal="Left" />
<ss:Font ss:Bold="1" />
</ss:Style>
<ss:Style ss:ID="2">
<ss:Alignment ss:Horizontal="Right" />
</ss:Style>
<ss:Style ss:ID="3">
<ss:Alignment ss:Horizontal="Center" />
</ss:Style>
</ss:Styles>

<ss:Worksheet ss:Name="F.Y.B.A. -2009-2010">
<ss:Table>
<ss:Column ss:AutoFitWidth="0" ss:Width="40" />
<ss:Column ss:AutoFitWidth="0" ss:Width="102" />
<ss:Column ss:AutoFitWidth="0" ss:Width="84" />
<ss:Row>
<ss:Cell>
<ss:Data ss:Type="String">First_Name</ss:Data>
</ss:Cell>
<ss:Cell>
<ss:Data ss:Type="String">Middle_Name</ss:Data>
</ss:Cell>
<ss:Cell>
<ss:Data ss:Type="String">Last_Name</ss:Data>
</ss:Cell>
</ss:Row>
<ss:Row>
<ss:Cell>
<ss:Data ss:Type="String">ABHILASH</ss:Data>
</ss:Cell>
<ss:Cell>
<ss:Data ss:Type="String">RAMDEV</ss:Data>
</ss:Cell>
<ss:Cell>
<ss:Data ss:Type="String">SHRIYAN</ss:Data>
</ss:Cell>
</ss:Row>
</ss:Table>
</ss:Worksheet>
</ss:Workbook>




Responses

Posted by: Abhi2434 on: 5/10/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
See this .. This will help :

http://www.db-staff.com/index.php/microsoft-sql-server/74-working-with-xml

www.abhisheksur.com

Man2vb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Man2vb on: 5/10/2010 [Member] Starter | Points: 25

Up
0
Down
Thanks for u r reply, but this is not expected.
I want to create exact XML using FOR XML EXPLICIT or any other method, can u give me the sample query for generating this XML file

Man2vb, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Er.deepakdalal on: 5/10/2010 [Member] Starter

Up
0
Down
Hi Man2vb

Try this link it will help you


http://blog.sqlauthority.com/2009/02/12/sql-server-simple-example-of-creating-xml-file-using-t-sql/

Man2vb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response