Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: 1675 | Views in the last 30 days: 2
 
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 age - Most easiest way

This function is used to calculate the age from the given date.

Tags
calculate    
clustering    
estimate    
heap    
non-clustered    
size    
space    
table    
used    
 
Contribute