SQLCMD does not write the results of a RESTORE command to the log file or tty

  • I'm in the process of converting some scripts we use to restore SQL Server databases to use SQLCMD.  The scripts currently use the osql utility.  I thought SQLCMD would have all the functionality of osql plus more but it doesn't seem to output the stats and a "RESTORE DATABASE successfully processed" to a file or monitor anymore from the restore command, as shown below.  Am I missing something and there is a way to enable this or do I have to rewrite in Powershell?  I don't really want to rewrite it in Powershell as our refresh process does much more than just restore the db, it also adds and removes db users, permissions and removes sensitive data as well as obfuscating it.

    5 percent processed.

    10 percent processed.

    15 percent processed.

    20 percent processed.

    25 percent processed.

    30 percent processed.

    35 percent processed.

    40 percent processed.

    45 percent processed.

    50 percent processed.

    55 percent processed.

    60 percent processed.

    65 percent processed.

    70 percent processed.

    75 percent processed.

    80 percent processed.

    85 percent processed.

    90 percent processed.

    95 percent processed.

    100 percent processed.

    Processed 47162496 pages for database '', file '' on file 1.

    Processed 29635744 pages for database '', file '' on file 1.

    Processed 8541304 pages for database '', file '' on file 1.

    Processed 273 pages for database '', file '_log' on file 1.

    RESTORE DATABASE successfully processed 85339817 pages in 485.631 seconds (1372.888 MB/sec).

    • This topic was modified 1 year, 2 months ago by  shaner.
  • I found the answer and it's to use the -m-1 flag it does produce other dross that needs to be cleaned out of the log but it does show the progress.

  • Thanks for posting that you found the answer. That'll prove helpful for the person who searches for the same issue and finds your original post.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Eventual command used and yes it is run from a linux shell script.  Used egrep to strip out the information messages.

    "${UTIL_DIR}/SQLCMD -H ${HOSTNAME} -S${HOST\INSTANCE} -dtempdb -U${USER} -P${PWD} -m-1 -i ${LOAD_FILE} | egrep -v "Msg 3211|Msg 4035|Msg 3014|Msg 5701|Msg 15457" | tee ${TMP_LOGFILE}

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply