Generating XML file

  • Hi, I'm looking for method on how to generate query result to an xml file from SQL Server 2000. The xml file which I refer to is a physical file and not an xml document in memory.

    Thanks in advance

  • TSQL all by itself can't write out to a file. From TSQL, to get to a file you'd need to call sp_OA procedures. Otherwise, I'd look at DTS as a method for going out to a file if you can't run something from a client like ADO.NET.

    Otherwise, TSQL can structure the data out to XML through FOR XML type queries. Then you just have to get the output to a file.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • When i want to generate XML file, i use QA and then i right click on the page and i choose result to file. Then, when you run your query the result will be written down in a file as an XML file.

    Naturally you should already know how to use the FOR XML type queries. If not, refer to the tutorial.

    Good Luck. 

  • By the way, I realized that it looks like I'm recommending sp_OA procs. I'm not. They're slow and memory pigs, but an option. Just wanted to clarify that.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

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

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