Microsoft SQL Server Retrieve information about the database Get the list of all databases on a server


Method 1: Below query will be applicable for SQL Server 2000+ version (Contains 12 columns)

SELECT * FROM dbo.sysdatabases

Method 2: Below query extract information about databases with more informations (ex: State, Isolation, recovery model etc.)

Note: This is a catalog view and will be available SQL SERVER 2005+ versions

SELECT * FROM sys.databases

Method 3: To see just database names you can use undocumented sp_MSForEachDB

EXEC sp_MSForEachDB 'SELECT ''?'' AS DatabaseName'

Method 4: Below SP will help you to provide database size along with databases name , owner, status etc. on the server

EXEC sp_helpdb

Method 5 Similarly, below stored procedure will give database name, database size and Remarks

EXEC sp_databases