- Open SQL SSMS Window
- Copy and paste the script
- Execute the query checking the intended database.
SQl Hunt,
2019-05-03 (first published: 2014-12-26)
- Open SQL SSMS Window
- Copy and paste the script
- Execute the query checking the intended database.
SELECT t.NAME AS TableName, i.name as indexName, p.[Rows], sum(a.total_pages) as TotalPages, sum(a.used_pages) as UsedPages, sum(a.data_pages) as DataPages, (sum(a.total_pages) * 8) / 1024 as TotalSpaceMB, (sum(a.used_pages) * 8) / 1024 as UsedSpaceMB, (sum(a.data_pages) * 8) / 1024 as DataSpaceMB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id WHERE t.NAME NOT LIKE 'dt%' AND i.OBJECT_ID > 255 AND i.index_id <= 1 GROUP BY t.NAME, i.object_id, i.index_id, i.name, p.[Rows] ORDER BY object_name(i.object_id)
Check out this stored procedure sp_rows to get a listing of space used and rows counts for your SQL Server database tables.
2018-10-10
3,405 reads
Dattatrey Sindol explains the different ways in which you can get the row counts from all the tables in a SQL Server database.
2017-06-22
5,549 reads
2014-01-17 (first published: 2014-01-03)
1,720 reads
The query will help to find whether my database backup to a specific instance of SQL Server is running fine. If HH> 1, this would signify that the backup is running, else this is a failure.
2019-05-03 (first published: 2012-08-25)
1,161 reads
The script helps to calculate the size of the backup of the databases monthwise. This will help to understand the database growth rate from the backup file if we do not have any data collection utility to find the exact details of the DATA File growth.
2019-05-03 (first published: 2012-08-20)
1,343 reads