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:

SQL Server Databases using EXEC

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.

Similar Reads

SHOW/LIST Databases in SQL Server

Listing all databases in SQL Server is a common task for database administrators and developers. SQL Server provides two main methods to solve this task are defined below:...

1. Using SELECT command

The below command results in all the databases including user-databases available in the system:...

2. Using EXEC command

The other approach of listing all the databases is using EXEC command . Here the below command displays all the system and user databases....

How to get the User-Created Databases Name in SQL Server?

If we want to fetch only the names and details of user created databases, we need to execute the below query. This query filters the known system databases and displays user created ones....

Conclusion

Overall, SQL Server offers a robust platform for managing databases, providing users with a range of tools and options for listing databases. Whether you prefer the flexibility of SQL commands or the user-friendly interface of SSMS, SQL Server caters to diverse user needs and environments. By following the techniques outlined in this article, you can efficiently navigate and manage databases in SQL Server....