saving XML stream to a file

  • I wrote a stored procedure that returns information in a specific format. Is there any way to save the XML stream in SQL automatically to a file with a certain name. Any help would be greatly appreciated.

    Patrick Quinn

    TRMS Database Administrator

  • You may want to try using an OSQL window to run the SP, then redirect the output to a file.

    for example:

    execute('MASTER.DBO.XP_CMDSHELL ''OSQL -U UserName -P ' -|- @PASSWORD -|- ' -Q "EXECUTE DataBase.DBO.SP_Name " -w116 -o' -|- @LOCATIONOFOUTPUTFOLDER -|- '\OutputFilename.TXT''')

    note -|- is a plus sign, but the forum interface keeps deleting them.

  • Well, that will work. However, I am getting this error message below.

    Cannot open output file - c:\xml\mscunits.xml

    No such file or directory

    The file and directory structure exists on the machine that QA is running. Is there something with xp_cmdshell or QA that needs to be modified in order to get it to execute and create the output file in the c:\xml directory?

    Patrick Quinn

    TRMS Database Administrator

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

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