A professional T-SQL script to analyze the storage usage of user tables in SQL Server — including detailed breakdown of data size, index size, and total space per table.
- Computes data size, index size, and total space used by each table.
- Calculates row count, and categorizes LOB and row-overflow pages.
- Returns results in KB & MB for easy monitoring.
- Ideal for performance tuning, storage planning, and database optimization.
- Microsoft SQL Server
- T-SQL
- SSMS (SQL Server Management Studio)
TableName | RowCounts | TableSizeKB | IndexSizeKB | TotalSizeMB |
---|---|---|---|---|
Orders | 250000 | 12,480 | 6,232 | 18.69 |
Customers | 55000 | 3,208 | 2,019 | 5.09 |
- Open SQL Server Management Studio.
- Paste the provided script into a new query window.
- Execute the query against your target database.
- Export the result if needed (CSV, Excel, etc.)
اسکریپت حرفهای T-SQL برای آنالیز فضای مصرفشده توسط جداول کاربر در SQL Server — شامل تفکیک کامل حجم داده، ایندکس و فضای کل به تفکیک جدول. مناسب برای مانیتورینگ و بهینهسازی فضای پایگاه داده.
سكريبت SQL لتحليل استخدام المساحة في جداول المستخدم داخل SQL Server، مع تقسيم حجم البيانات والفهارس والمساحة الإجمالية لكل جدول.
sql
tsql
sql-server
table-size
index-size
storage-analysis
database-performance
dba
sql-diagnostics