How to Get Size of All Tables in SQL Server

June 28, 2018 // In: How To

Sometime there is simple solution to a complex problem.

Few days ago, I have to find each database table sizes (disk space used by every table) and number of rows for database optimization purpose. When we think about such kind of problem, we may think that could be difficult to find disk space used by every table, but we can easily count number of rows in every table of a database by getting database tables from master database. But how to find disk space used by tables? Question is very complex, but the answer is very simple.

We can use following query to get  rows count and disk space used by each database table. This query will return disk space in KB,  shows result in a second and It’s neither lock any table nor disturb your production work.

Result

 

 

How to Kill Database Connections (SQL Server)