Get a Rough Estimate of Disk Space for Data and Indexes

Get a Rough Estimate of Disk Space for Data and Indexes

sp_spaceused can be used to compute the amount of disk space used for data and indexes, and the disk space used by a table in the current database. If no table is given, then sp_spaceused reports on the space used by the entire current database. For example:

sp_spaceused MyTable [, Optional true or false to
specify if DBCC UPDATEUSAGE is also run]go

A known limitation of this stored procedure is that it reports inaccurate information after an index is dropped. This is because this stored procedure queries the sysindexes table and is completely dependent on that table for its accuracy.

However, sp_spaceused can provide a quick, rough estimate of values. DBCC UPDATEUSAGE can be run to correct the inaccuracies if incorrect values are noticed when executing sp_spaceused. The stored procedure can also take an optional parameter to specify whether or not DBCC UPDATEUSAGE should be run. Another option is to run DBCC UPDATEUSAGE separately. To run DBCC UPDATEUSAGE with the stored procedure use: sp_spaceused MyTable, True.

See also  How College Students Can Shape the Future of Tech Responsibility

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist