Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

DATABASE / TABLE SIZE ESTIMATER

By Amit Jethva,


The code in this procedure takes standard formula’s given by Microsoft and calculates approximate size of a table as per the fields  & indexs on that table. The procdure can be quickly be used in a loop to work for entire database.



Refer to article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_02_92k3.asp


for the actual document containing the formula’s used.

There are 2 major assumptions made
1. All The VARIABLE LENGTH columns will be completely filled. (you can change it easily)
2. FillFactor for all indexes in tables are same.

Usage:
declare  @objectid int, @num_rows float , @fill_factor  smallint
select @objectid = object_id('authors'), @num_rows = 2000 , @fill_factor = 90
exec gettablesize ( @objectid ,@num_rows ,@fill_factor  )

Rerurns:
Row Size , Data Size in KB, Clustered Index Size in KB,NonClustered Index Size in KB and total Size in KB



Total article views: 2773 | Views in the last 30 days: 9
 
Related Articles
FORUM

Default Index Fill Factor

System default of 0 fill factor

FORUM

Fill factors, index fragmentation and indexing strategy

Do I need to specify a fill factor for a specific scenario?

FORUM

Fill Factor clarification

Fill Factor clarification

FORUM

Rebuilt clustered index with new fill factor

new filll factor is not reflected in avg_page_space_used_in_percent

BLOG

What is the best value for Fill Factor in SQL Server?

Introduction When an index is created or rebuilt, the fill-factor value determines the percentage o...

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones