query to get dbname,totalsize,reservedsize of all databases in sql 2000

  • Hi,

    required query for me to work on sql 2000 server is

    query to get dbname,totalsize,reservedsize of all databases in sql 2000.

    Any body have so or query ples let me know.

    Thanks in advance

    Syamala

  • No perfect answer but maybe it can push you in the right direction.

    create table #tbl (name varchar(128), s bigint)

    declare @db varchar(128)

    declare @sql varchar(2048)

    select @db = ''

    while exists (select Name from master..sysdatabases where name > @db)

    begin

    select top 1 @db = Name from master..sysdatabases where name > @db order by Name

    select @sql = 'insert into #tbl (Name, s) select ''' + @db + ''', sum(size) from ' + @db + '..Sysfiles'

    exec(@sql)

    end

    select * from #tbl

    drop table #tbl

    /T

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

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