Every once in a while, you may have a need to determine how much space is being used by a table in your database. In this quick blog, I am going to show you how to get the some details on a particular table using the system stored procedure sp_spaceused. I’m not going to try and rehash what MSDN has to say about sp_spaceused, but I would encourage you to check it out when you have time.
For this example, I want to determine the amount of space the DimProducts table is taking up in the AdventureWorksDW database. Script 1 below shows how to pass in the table name to the sp_spaceused procedure and figure 1 displays the results of executing the script on my machine. Yours may vary based on what you’ve done to the table after installing the AdventureWorksDW database.
Script 1: sp_SpaceUsed
EXEC sp_spaceused DimProduct
Figure 1: Results
There you have it. It’s simple enough right? Go ahead and give it a try.
Until next time, “keep your ear to the grindstone” – Good Will Hunting
Brian K. McDonald, MCDBA, MCSD
Business Intelligence Consultant – Pragmatic Works Consulting
Email: email@example.com | Blog: BI Developer Network
Convert with DTS xChange | Develop with BI xPress | Process with TaskFactory | Document with BI Documenter