SQL Script - How to get the table size, index size and last user update

08 January,2016 by Jack Vamvas

Question: How can I get a list of every table in a database, with auxillary information including numbers of rows, data space, index space, percent of database?

I’ve read through the post and sql script on  SQL Index Usage - SQL Server DBA  but it doesn’t include certain information. Do you have a script returning this table detail?

Answer: A colleague of mine offered this script , which returns the sort of table detail you require. He can’t remember who gave him the script, so thank you to the mystery author.

This script includes returning indexes and metadata per index in the tables. It is very useful particularly if you’re reviewing tables within a database.

I manage SQL Server databases and as part of regular maintenance of the databases, thi s is the sort of information to analyse. It’s not unusual to find tables that are now redundant , these can be offered to the owner , who may decide to drop or archive the table.

Download Tablesize_and_last_user_updates

These sort of tactics assist in streamlining the databases. It will be quicker to run maintenance plans and backup.


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on SQL Script - How to get the table size, index size and last user update


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer