How to use EXEC command In SQL
The other approach of listing all the databases is using EXEC command . Here the below command displays all the system and user databases.
EXEC sp_databases;
Output:
Explanation: The above query ‘EXEC sp_databases’ selects and displays database_name, database_size, and remarks of all the databases present in the SQL Server system.
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.