Extract sqlcmd output to multiple files

  • Can you please suggest how to extract sqlcmd output to multiple files?

    sqlcmd -E -S server -d master -Q "exec master..proc" -o "D:\out\file.sql" -o "\\servername\logins\file.sql"

    This throws an error :
    Sqlcmd: Option '-o' cannot be specified multiple times.'

    Kindly suggest an alternate workable method.

    Thanks.

  • SQL-DBA-01 - Thursday, January 19, 2017 9:32 AM

    Can you please suggest how to extract sqlcmd output to multiple files?

    sqlcmd -E -S server -d master -Q "exec master..proc" -o "D:\out\file.sql" -o "\\servername\logins\file.sql"

    This throws an error :
    Sqlcmd: Option '-o' cannot be specified multiple times.'

    Kindly suggest an alternate workable method.

    If its the same file, one option would be to create a batch file, call the sqlcmd statement first and for the next statement, copy the file to the other location.

    Sue

Viewing 2 posts - 1 through 1 (of 1 total)

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