Output to XML File

  • How can I save the query output to XML file? for example following statement produces XML resultset in Query Analyser.

    Select * from Employees For XML, Element.

    I want to save the resultset to an XML file.

    Please help me.

    Shifan,

    qaqa


    qaqa

  • Why don't you run the same query from OSQL and send the output to a file?

    Cheers,

    - Mark


    Cheers,
    - Mark

  • Query analyzer has many limitations in formating results

    - The maximum number of characters allowed are only 8192 per column

    (where for xml tries to output data as single column value)

    - You can use save results to file option(in options) again the size is limited by 8192.

    One alternative would be to use url query if you have configured SQL XML

    support for IIS.

    http://localhost/VirDirNameHere?sql=select * from EMPLOYEE for xml

    auto, elements&root=employee

  • I have tried by using OSQL, it has not worked. I have done through following steps:

    1. Create a q1.qry file with the following SQL statement

    Use Northwind

    Select * from Employees For XML Auto,

    Elements

    2. From DOS console I have entered

    following QSQL command.

    OSQL /U sa /P /i q1.qry /o aa.xml

    After executing, encounted an error saying "OS Error 120 (Null). I do not know what is this error. And opened the aa.xml file the following message was written

    [Shared Memory]SQL Server does not exist or access denied.

    [Shared Memory]ConnectionOpen (Connect()).

    Please clarify why this happened.

    Shifan.

    qaqa


    qaqa

  • Try an add the S paramter for the SQL Server.

    Mine worked with

    OSQL /i c:\xml.sql /o aa.xml -SLENE -E -w10000

  • Still same error encountered.

    qaqa


    qaqa

Viewing 6 posts - 1 through 6 (of 6 total)

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