SQLCMD capture output from :ServerList to a file?

  • Is there a way to have the output from :ServerList redirected to a file?

    I tried :ServerList -o C:\Test.txt

    and

    :serverlist :Out C:\Test.txt

    Tks.

  • Hi John,

    I guess by now you have found:

    sqlcmd -Lc > c:\serverlist.txt

    Alternatively, you can put your :serverlist in a script file and use the sqlcmd switches

    -i (input file) and -o (output file)

    Regards, Michael

  • Michael

    Thanks for that. I had not got it working as I have been way too busy on a couple of projects.

    I will get back to the proj where I was trying to capture the server data into a file soon after new year.

    Happy Holidays

    Regards JOHN.

  • Using Powershell is simple, the syntax is sqlcmd -Lc | Out-File c:\serverlist.txt

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

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