This script calculates table row count and size(MB), as well as the used space and free space.
1 OPEN SSME
2 SELECT YOUR DB WHICH YOU WANT TO RUN
3 COPY AND PASTE THE SCRIPT THEN RUN
dg-65441,
2014-01-31 (first published: 2014-01-17)
This script calculates table row count and size(MB), as well as the used space and free space.
1 OPEN SSME
2 SELECT YOUR DB WHICH YOU WANT TO RUN
3 COPY AND PASTE THE SCRIPT THEN RUN
if exists(select * from tempdb..sysobjects where id = OBJECT_ID('#temp_table1')) drop table #temp_table1 GO select B.name,CONVERT(numeric(30,3),(CONVERT(float, SUM(A.used_page_count)*8)/1024)) as [Table Used Size(MB)], CONVERT(numeric(30,3),(CONVERT(float, SUM(A.reserved_page_count)*8)/1024)) as [Table Located Size(MB)], (CONVERT(numeric(30,3),(CONVERT(float, SUM(A.reserved_page_count)*8)/1024)) - CONVERT(numeric(30,3),(CONVERT(float, SUM(A.used_page_count)*8)/1024))) as [Table Free Size(MB)] , A.row_count into #temp_table1 from sys.dm_db_partition_stats as A, sys.all_objects as B where A.object_id = B.object_id and B.type != 'S' group by name,row_count order by B.name asc Select * from #temp_table1 drop table #temp_table1
A quick script that provides the sizes of the tables in your database, including schema and choice of sort method
2018-08-07 (first published: 2018-07-29)
725 reads
2016-07-04 (first published: 2016-06-08)
837 reads
This quick and dirty sql will tell you the number of rows in your tables, the size in MB of yout data, and the total size (including indexes)
2009-05-05 (first published: 2008-10-04)
1,643 reads
Two views that give you a variety of stats, sortable as a percent of DB size, for tables, indiceses, XML indices, and Service Broker Queues.
2012-10-09 (first published: 2008-06-16)
3,049 reads
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