Welcome to MSDN Blogs Sign in | Join | Help

SYSK 360: What’s taking up the space in my database? Also, a word about SQL reports…

So, you’ve updated usage stats on your database by running

 

EXEC sp_spaceused @updateusage = N'TRUE'

 

But, you still can’t figure out why it’s reporting much more used space then the data that appears in your tables…

Try running the following query to get number of rows and detailed space usage information for each table and each index.

 

SELECT object_name(object_id) as ObjName,

      index_id as IndexID,

      sum(in_row_data_page_count) as InRowDataPages,

      sum(lob_used_page_count) as LargeObjectPages,

      sum(row_overflow_used_page_count) as RowOverflowPages,

      sum(row_count) as Rows

FROM sys.dm_db_partition_stats

GROUP BY object_id,index_id

GO

Also, there are a number of commonly used reports that are available in SQL Server Management Studio.  Just right-mouse click on the database, and choose Reports -> Standard Reports…

While I am on the SQL reports topic, you can also get a number of useful reports for the entire server,  e.g. All Blocking Transactions, Top Queries by Average CPU time, Top Queries by Average IO, Schema Changes History, Memory Consumption and many more!  Simply, right-mouse click on the server name and choose Reports ->Standard Reports…

Finally, one more query that can come in handy:

SELECT * FROM fn_trace_gettable ('C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\log.trc', default) GO

 

Special thanks to Curtis Krumel and Saleem Hakani for the queries above!

Published Tuesday, August 07, 2007 5:37 PM by irenak
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# SYSK 360: What’s taking up the space in my database? Also, a word about SQL reports…

Tuesday, August 07, 2007 9:08 PM by Noticias externas

So, you’ve updated usage stats on your database by running EXEC sp_spaceused @updateusage = N 'TRUE'

# re: SYSK 360: What’s taking up the space in my database? Also, a word about SQL reports…

Wednesday, August 08, 2007 5:16 AM by alexander walker

doesn't seem to work on sql 2k

# SYSK 360: Reply to Alexander Walker

Thursday, August 09, 2007 8:21 AM by irenak

Yes, it's only for 2005.

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker