Using following methods, we can get list of all databases on server.
Method 1: Using sp_databases
System stored procedure "sp_databases" lists databases of SQL server instance.
The result
set of this stored procedure contains Database name, size and remark as column
Method 2: Using sp_helpdb
System stored procedure sp_helpdb reports the information about all database or specific database.
The result set of this stored procedure returns database name,size,owner,database Id, created date, status and compatibility level as column
Method 3: Using system
table “sys.databases“
System table "sys.databases" contains all the databases in the instance of SQL server.
- SELECT name FROM sys.databases
Method 4: Using
system table “sys. Sysdatabases”
The system table "sys.Sysdatabases" contains all database in instance of SQL Server
- SELECT name FROM sys.sysdatabases
Hope this help.