how to capture database size

  • i m creating a script and for that i need database size..

    i can use sp_helpdb but dbsize is in nvarchar and it has mb included in it...

    is there any way to capture only the integer part of it..so that i can do calculations on it.

    i was thinking of using substring but i think its not feasible.

  • Pulled from script originally written to run against 2000 but works in 2005

    SELECT sum(convert(int,round((aa.size*1.000)/128.000,0)))

    FROM dbo.sysfiles aa

    LEFT JOIN dbo.sysfilegroups bb ON aa.groupid = bb.groupid

    _____________________________________________________________________
    - Nate

    @nate_hughes
  • thnaks but i wanted the size of all databases present.by using ur script we first have to got to that database then run this script.

  • These scripts should give you the information you are after.

    Get Server Database File Information for all databases on a server

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=89058

    Script to analyze table space usage within a database

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61762

Viewing 4 posts - 1 through 3 (of 3 total)

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