Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Size of Data

Author  Topic 

jimmpy
Starting Member

15 Posts

Posted - 2006-06-27 : 10:38:58
Is there any way to find out total size of all the user/sys DBs and Data space used (in % or MB)? Just like DBCC SQLPERF (LOGSPACE)

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-06-27 : 10:47:50
there is "sp_spaceused" for one db at a time.

For a quick, approximation of all DBs, I use this sometimes:

--List the approximate size of all databases on server

set nocount on
if object_id('tempdb..#temp') > 0
drop table #temp
create table #temp (db sysname, size int)

declare @dbid int
,@sql varchar(2000)
select @dbid = min(dbid) from master..sysdatabases
while @dbid is not null
begin
set @sql = 'select ''' + db_name(@dbid) + ''', sum(size) from ' + db_name(@dbid) + '..sysfiles'
insert #temp(db, size)
exec (@sql)

select @dbid = min(dbid) from master..sysdatabases where dbid > @dbid
end

--size column in sysfiles is in 8 KB pages
select ((size*8)/1024)/1024.0 [GB], db from #temp order by size desc


Be One with the Optimizer
TG
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-27 : 10:55:00
Also refer
http://sqlteam.com/forums/topic.asp?TOPIC_ID=53843
http://sqlteam.com/forums/topic.asp?TOPIC_ID=61762


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jimmpy
Starting Member

15 Posts

Posted - 2006-06-27 : 11:22:38
Thanks, but I was more interested in seeing % SPACE USED for each Database.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-28 : 02:28:42
Run this

Select 'EXEC '+name+'..sp_spaceused' from Master..sysdatabases

Copy the result back to QA and run them one by one

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -