BCP to XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guswebb
    New Member
    • Jul 2007
    • 11

    #1

    BCP to XML

    i'm running bcp to output some MSSQL table content to XML. i can get the xml output file fine but am having problems with the insertion of the <root> open and close tags.

    the code that I'm using is as per various threads that i've found on the net, but i get an 'unknown argument on command line' error as follows...

    unknown argument 'rootopen.txt+m yfile.xml+rootc ls.txt' on command line.

    the code i am using is...

    Code:
    bcp "SELECT * FROM DBNAME..TABLENAME FOR XML RAW" queryout myfile.xml -SSERVERNAME -T -c -r -t copy/b rootopen.txt+myfile.xml+rootcls.txt myfile.xml
    the xml output file is produced and saved in the same directory as where the rootopen.txt and rootcls.txt files are saved, however the subsequent copy process to merge all 3 files doesn't appear to work.

    any ideas?
  • guswebb
    New Member
    • Jul 2007
    • 11

    #2
    i have now fixed the problem of inserting the root tags.

    my next problem is that in the process of doing this, i am creating a temporary file called myfiletemp.xml. once the bcp process has completed, i no longer need this file, so i am appending the command to delete it to my bcp command, as follows...

    del /Q myfiletemp.xml

    for some reason, this still prompts me with a Y/N option, asking if i'm sure that i want to proceed. my understanding is that the /Q switch should force the process not to prompt, so i'm scratching my head a bit on this one.

    i have also tried the above with /S and /F switches individually and together, but still the same problem.

    the file deletes fine if i respond with Y at the prompt, but i really want this process to complete without user interaction so that it can run as a scheduled task.

    i'm using W2k3 if this has any bearing on the problem.

    Comment

    Working...