Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Export SQL Query Result Set to text file

Author  Topic 

drintharamy
Starting Member

1 Post

Posted - 2011-08-15 : 10:12:15
I have the following stored procedure and I would like to export the result set from stored procedure to a text file:

EXEC master..xp_cmdshell 'SQLCMD -S SERVER -E -Q "spPDFILE1" -b -o C:\temp\myoutput.txt', no_output

When I ran the above command, I got message stating "Command(s) completed successfully but I can not find my "myoutput.txt" file.

Help!

Thank you!

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-08-15 : 16:28:04
try this:

EXEC master..xp_cmdshell 'SQLCMD -S SERVER -E -Q "spPDFILE1" -b -o C:\temp\myoutput.txt'

and let us know what message(s) you get

Cheers
MIK
Go to Top of Page
   

- Advertisement -