How to use the sp_databases Stored Procedure In SQL
Yet another option to get the size of a database in SQL Server is the sp_databases system stored procedure路 This stored procedure lists databases that either reside in an instance of the SQL Server or are accessible through a database gateway路
To use it, we simply execute it without any argument.
EXEC sp_databases;
Output:
Explanation: This will return one result set that shows the name, the size, and the remarks of each database.
Advantages and Disadvantages of using sp_databases Stored Procedure
Advantages |
Disadvantages |
---|---|
It is compatible with earlier versions of SQL Server and other database systems. |
|
How to Get Database Size in SQL
SQL database size is vital for effective management. It indicates the storage space occupied by tables, indexes, and other components. Knowing the size of a database is useful for various purposes, such as monitoring the growth, estimating the backup time, planning the storage capacity, and optimizing performance路
In this article, we will learn how to get the size of a database in SQL Server using different queries or management tools.