There are a number of ways to list databases from an SQL 2005 Server.
-- Easiest way is to use the undocumented SQL 2005 stored procedure exec sp_msForEachDB 'PRINT ''?''' -- Query the sysdatabases table (for SQL 2000 and 2005) select * from sysdatabases -- query the sys.sysdatabases table (for SQL 2005) select * from sys.sysdatabases -- Stored procedure to list all databases EXEC sp_databases -- Stored procedure to list specific information about a single database or all databases. EXEC sp_helpdb