Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Lists databases that either reside in an instance of the SQL Server or are accessible through a database gateway.
Transact-SQL syntax conventions
sp_databases
[ ; ]
None.
Column name | Data type | Description |
---|---|---|
DATABASE_NAME |
sysname | Name of the database. In the Database Engine, this column represents the database name as stored in the sys.databases catalog view. |
DATABASE_SIZE |
int | Size of database, in kilobytes. |
REMARKS |
varchar(254) | 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.
DATABASE_SIZE
returns a NULL
value for databases larger than 2.15 TB.
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. Can't be denied VIEW ANY DEFINITION
permission.
The following example shows executing sp_databases
.
USE master;
GO
EXEC sp_databases;
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!