How to use SELECT command In SQL
The below command results in all the databases including user-databases available in the system:
SELECT name FROM sys.databases;
Output:
Explanation: SELECT statement selects the NAME of the system databases including user-created databases using SYS.DATABASES command.
We can also display only required information of databases in the system, we use the query as below:
SELECT name, database_id, create_date FROM sys.databases;
Output:
Explanation: The above query displays name, database_id, and create_date of system databases and user-created databases using SELECT and SYS.DATABASES command.
SQL Server Show/List Databases
Listing all databases in SQL Server is a common task for database administrators and developers. SQL Server provides two main methods to solve this such as using SQL commands and using SQL Server Management Studio (SSMS). In this article, we will learn about how to Show/List the SQL Server Databases using both approaches in detail.