We help IT Professionals succeed at work.

sqlcmd; output file

I using the sqlcmd from a batch file.  I'm calling it more than once.  However, I would like the results from all calls to be in a single  output file (-o parm).

Can this be done?
Comment
Watch Question

Doug BishopDatabase Developer
Commented:
will redirection work? Remove the -o and use:
sqlcmd .... >> myoutput.txt. The double > will append to the existing file (or create it if it doesn't exist.
Commented:
sqlcmd -S “ServerName” -U “UID” -P “PWD” -d “DBName” -i “c:\input.txt” -o “c:\output.txt” -s “,” -h -1

for more details refer below links..

http://www.siusic.com/wphchen/sqlcmd-example-to-output-in-csv-format-350.html

http://msdn.microsoft.com/en-us/library/ms162773.aspx
hi test on my desktop check the image attached
sqlcmd out to a file tested on my desktiop

Author

Commented:
Thanks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.