Estimate the table size for SQL 2005 and 2008

  • pravallika.mca06

    SSC Enthusiast

    Points: 140

    Hi All,

    i have to estimate the table size based on the no of rows.

    If user enters table name and no of rows, i need to tell teh size occupied by the rows.

    Can somebody help on this.

  • Old McDonald

    SSCertifiable

    Points: 5768

    Create procedure Estimate(

    @Rows int

    ,@TableName varchar(32)

    )

    AS

    select sum(length)* @Rows AS SizeInBytes

    from sys.syscolumns

    where id = object_id(@TableName)

    But this code will give you the maximum size your row will occupy because it sums the size defined of all the variable data types (like varchar).

    -Vikas Bindra

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply