Home Forums SQL Server 2005 Administering Database list from multiple SQL servers and instances??? RE: Database list from multiple SQL servers and instances???

  • @angelspawn

    Part of the challenge to be a successful DBA is to use the tools at our disposal to answer these types of questions. There are [several] ways to answer your own question using batch files, PowerShell, SSMS, scripts, etc.

    My batch file suggestion is only one possible way to accomplish this. I'll assume you have administrator access to all SQL Servers in your domain. Check [font="Courier New"]dblist.txt[/font] on completion.

    [font="Courier New"]

    @ECHO OFF

    SQLCMD -Lc > serverlist.txt

    FOR /F %%i IN (serverlist.txt) DO (

    SQLCMD /S %%i /E /d master -o dblist.txt /Q"SET NOCOUNT ON SELECT SUBSTRING(@@SERVERNAME, 1, 30) AS ServerName, SUBSTRING([name],1,40) AS DBName FROM sysdatabases ORDER BY NAME SET NOCOUNT OFF;"

    )

    [/font]