sqlcmd; output file

Posted on 2012-08-15
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?
Question by:HLRosenberger
    LVL 15

    Assisted Solution

    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.
    LVL 9

    Accepted Solution

    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..
    LVL 10

    Assisted Solution

    hi test on my desktop check the image attached
    sqlcmd out to a file tested on my desktiop
    LVL 1

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now