Sample Header Ad - 728x90

When should sp_spaceused be used to get the size of a database, instead of querying sys.database_files?

0 votes
1 answer
140 views
I frequently find the output of sp_spaceused misleading. What appears to be the size of all data in a database is actually [the combined size of both the data file and the log file](https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-spaceused-transact-sql?view=sql-server-ver16#result-set) . I have recently discovered sys.database_files and I have found it superior in every way. It is so much better than sp_spacedused that I am planning to drink until I forget about that procedure. This give me my question: **When checking the size of a database, is there any feature or return value offered by sp_spacedused that cannot be obtained from sys.database_files?** I've checked over the documentation and I'm pretty sure that there isn't.
Asked by J. Mini (1237 rep)
Oct 30, 2024, 09:10 PM
Last activity: Oct 31, 2024, 12:22 AM