Convert SQL Table to XML...

  • Hello All,

    I have a table with the following structure with full of data:

    CREATE TABLE errorLog(

    [ID] [int] IDENTITY(1,1) NOT NULL,

    [params] [varchar](max) NULL,

    [vals] [varchar](max) NULL

    )

    I suppose, SQL Server 2008 supports XML widely and I am wondering whether i can convert the above table data to xml with the table structure easily and automatically.

    So, the XML representation would look something like this:

    <errorLog>

    <ID>1</ID>

    <ID>params</ID>

    <ID>vals</ID>

    </errorLog>

    Any help or suggestions are greatly appreciated.

  • If you want to select the data and convert it to XML, you need to look at the FOR XML clause. Check out thisMSDN link.

  • Thank you for your quick response. That should do it.:-)

  • please send how to convert sql table convert to xml files??/

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply