Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

sp_databases (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Lists databases that either reside in an instance of the SQL Server or are accessible through a database gateway.

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions


Column name

Data type




Name of the database. In the Database Engine, this column represents the database name as stored in the sys.databases catalog view.



Size of database, in kilobytes.



For the Database Engine, this field always returns NULL.

Database names that are returned can be used as parameters in the USE statement to change the current database context.

sp_databases has no equivalent in Open Database Connectivity (ODBC).

Requires CREATE DATABASE, or ALTER ANY DATABASE, or VIEW ANY DEFINITION permission, and must have access permission to the database. Cannot be denied VIEW ANY DEFINITION permission.

The following example shows executing sp_databases.

USE master;
EXEC sp_databases;

Community Additions

© 2015 Microsoft