Converting SQL Qry into XML and store as XML file

  • Hi There,

    My requirement is to read from a table in SQL 2000 and need to export the

    data in a XML format with .XML in a flat file.

    I don't want to do to use ADO or VB or any other external tools to do this. I want it to be purely done using SQL server within enviroment.

    How to generate this kind of XML files from

    SQL server?.

    Kindest regards,

    Chris.G

  • Im not aware of a method of doing this. Maybe the closest you could come would be to use the sp_oa~~ procs to use ADO or file scripting object, or even the XML DOM.

    I'm curious why you have this requirement? The easiest way in the world to do this is to use an ADO recordset and just persist to disk as XML. Any xml guru worth their salt can transform that into "normal" xml if need to.

    Andy

  • U can select the columns from table and use FOR XML clause to get data in XML format

    E.g.

    SELECT Customers.CustomerID, Orders.OrderID, Customers.ContactName

    FROM Customers, Orders

    WHERE Customers.CustomerID = Orders.CustomerID

    FOR XML AUTO

    Regd storing data in file i guess will have to depend on objects like ADO.

  • Hi

    You can do a roundabout way by setting the Result Options in the query Analyser to File and using the for xml explicit option to specify the output format

    Lata

  • check out my article at:

    http://www.sqlservercentral.com/columnists/jwiner/forxml.asp

    I used sp_webwebtask to do what I think your trying to accomplish.

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

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