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)

Estimating the table size...

By sql frenzy,

Well.... it's bit lengthy; I have used 6 functions to get the table size. Table size returned is in KB.

 

  1. fn_CalculateHeapSize: This function calculates the size of heap i.e when no clustered index has been defined.
  2. fn_ClusteredIndexSize: This function calculate the clustered index size.
  3. fn_GetNonClusteredIndexSize: This function calculate the size of all non-clustered index.
  4. fn_GetTableSize: This function combines the result of above functions to give the final results.
  5. fn_getIndexSpace: A common function used for calculation in above functions.
  6. fn_GetLeafLevelIndexSpace: A common function used for calculation in above functions.
  • Usage: select dbo.fn_GetTableSize('tablename')

Note:

I have not considered the LOB cols. in my calculations; also this is an estimation of a table size as given in BOL "Estimating the table size"

 

Total article views: 1607 | Views in the last 30 days: 7
 
Related Articles
FORUM

lag function calculation

llag function calculation

SCRIPT

Calculate Age

This a function by which you can calculate the age of something.

BLOG

Problem Using the Aggregate Function with Calculated Measures

Recently, I was working with a client we were working on a calculated measure using the aggregate fu...

FORUM

Need a function to Calculate Next Business Days

Need a function to calculate next business day considering holiday list and also saturday and sunday...

SCRIPT

Calculate gregorian easter sunday using a table valued function

Calculate gregorian easter sunday using a table valued function.

Tags
calculate    
clustering    
estimate    
heap    
non-clustered    
size    
space    
table    
used    
 
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