Dai
Dai

Reputation: 154995

SQL Server - Database size numbers don't add up

I'm using the query from this QA, verbatim, to get a size report of all of the tables in my database ( Get size of all tables in database )

When I run it, I get these values in the TotalSpaceKB column:

TableName         |  RowCounts   | TotalSpaceKB
Accounts                116507            27040
Calls                  9687278          3903176
Categories                  13               16
Clients                      9               16
CountryCosts                14               16
CreditTransactions      218664            41200
DoNotCallList            40282             6120
Hosts                  2166947           190080
MoneyTransactions         3907              464
PayPalIpns                3907             1880
Products                   402              216
ProductsInCategories       263               16
Queries                     15               32
QueryParameters             15               16
Settings                    26               16
Sites                        9               16
Templates                   65               56

Sum of TotalSpaceKB is 4,170,376 KB: 4GB

But when I go SSMS > Database > Properties > General > Size > 37795.25 MB : 37GB

I don't have filesystem access so I can't get the exact file sizes. But why the discrepancy?

Upvotes: 1

Views: 174

Answers (1)

Szymon
Szymon

Reputation: 43023

Yes, the missing bit is the transaction log. What is shown in the properties window is the total size of all files that are used by a database. The query you used measures only the size of data but not the transaction log.

Upvotes: 2

Related Questions