How to use the sp_helpdb Stored Procedure In SQL

Another system-stored procedure that can be used to get the size of a database in SQL Server is sp_helpdb· 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 can either provide the name of the database as an argument or execute it without any argument.

EXEC sp_helpdb N'tempdb';

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.

Similar Reads

Get SQL Database Size

The size of a database in SQL Server may be measured in exclusive ways, depending on what we need to include or exclude· For instance, we can measure the scale of the facts documents, the log documents, the reserved space, the used area, the unallocated area, or the whole space· We also can measure the size of a single database, a set of databases, or all databases within the server....

Using the GUI Tools

One of the easiest ways to get the size of a database in SQL Server is to use GUI tools, such as SQL Server Management Studio (SSMS) or Azure Data Studio· These tools provide various reports and properties that display the size of a database in a user-friendly way·...

Using the sp_spaceused Stored Procedure

Another way to get the size of a database in SQL Server is to use the sp_spaceused system stored procedure· This stored procedure displays the number of rows, disk space reserved, and disk space used by a table, indexed view, or Service Broker queue in the current database, or displays the disk space reserved and used by the whole database·...

Using the sp_helpdb Stored Procedure

Another system-stored procedure that can be used to get the size of a database in SQL Server is sp_helpdb· This stored procedure lists databases that either reside in an instance of the SQL Server or are accessible through a database gateway·...

Using the sp_databases Stored Procedure

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·...

Using the sys.master_files Catalog View

Another way to get the size of a database in SQL Server is to use the sys·master_files catalog view· This view contains a row per file of a database as stored in the master database·...

Using the sys.databases Catalog View

The last method we will cover in this article is to use the sys·databases catalog view· This view contains one row per database in the instance of SQL Server·...

Conclusion

This article explained various methods to determine a database size in SQL Server, including GUI tools, system stored procedures, and system catalog views·...