?
Solved

sqlcmd; output file

Posted on 2012-08-15
4
Medium Priority
?
1,112 Views
Last Modified: 2012-08-20
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?
0
Comment
Question by:HLRosenberger
4 Comments
 
LVL 15

Assisted Solution

by:dbbishop
dbbishop earned 668 total points
ID: 38297255
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.
0
 
LVL 9

Accepted Solution

by:
keyu earned 668 total points
ID: 38299449
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
0
 
LVL 10

Assisted Solution

by:Ramesh Babu Vavilla
Ramesh Babu Vavilla earned 664 total points
ID: 38299738
hi test on my desktop check the image attached
sqlcmd out to a file tested on my desktiop
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 38312059
Thanks
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question