Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Stored Procedure Output to a File

Avatar of ReneLMadsen
ReneLMadsen asked on
8 Comments1 Solution447 ViewsLast Modified:
Hello All,

I have written two stored procedures; the first is a FOR XML EXPLICIT query, the second executes the first and should output the result to an XML file.

The first 'sp_XML_TEST' works in SQL SERVER Query Analyser, the second 'sp_XML_OUTPUT' doesn't.

sp_XML_OUTPUT contains the following:


EXEC master..xp_cmdshell 'OSQL -S [local] -U sa -P mbl1175 -d SCLAnodising -Q "EXEC sp_XML_TEST" -O D:\Company Shared Folders\Croxford\XML_OUTPUT.xml'

The output I get is:

usage: osql              [-U login id]          [-P password]
  [-S server]            [-H hostname]          [-E trusted connection]
  [-d use database name] [-l login timeout]     [-t query timeout]
  [-h headers]           [-s colseparator]      [-w columnwidth]
  [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]
  [-L list servers]      [-c cmdend]            [-D ODBC DSN name]
  [-q "cmdline query"]   [-Q "cmdline query" and exit]
  [-n remove numbering]  [-m errorlevel]
  [-r msgs to stderr]    [-V severitylevel]
  [-i inputfile]         [-o outputfile]
  [-p print statistics]  [-b On error batch abort]
  [-X[1] disable commands [and exit with warning]]
  [-O use Old ISQL behavior disables the following]
      <EOF> batch processing
      Auto console width scaling
      Wide messages

Can anybody tell me where I'm going wrong?

Secondly, can I combine the two?

Thank you for any help you can offer
Avatar of Aneesh
AneeshFlag of Canada imageDatabase Consultant
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers