Link to home
Start Free TrialLog in
Avatar of son_robin
son_robin

asked on

Find database size in query analyzer

For SQL Server 2000, I'd like to know the way of looking the database and log size with the Query Analizer. sp_spaceused gives only the current usage. I want to find the total size of the database.

Thanks,
Robinson.
Avatar of Jan Franek
Jan Franek
Flag of Czechia image

Try sp_helpdb
Avatar of son_robin
son_robin

ASKER

This gives the current size only. I want the Total Size of the DB and/or Space Available. If you click on the Database properties from Enterprise Manager these details are there. I want to find from query analyzer.
And what about sp_helpdb with database name. It shows me total size of all segments and also free space on each of them. But I'm on Sybase and may be, MS SQL will show you something else.

You can get this using T-Sql, I have scripts that will give you DB size, backup size and space left on disc X.

But I cant provide it until I'm back to work on monday.
I will wait for monday Nilsson. Thanks a lot
Here's what EM does (amongst a lot of other things)

select [Total size in KB]=sum(convert(float,size)) * (8192.0/1024.0) from dbo.sysfiles

exec sp_spaceused

DBCC SQLPERF(LOGSPACE)

Again you are giving me ways to find Used space. I need the total size!!!
What the heck do you think that first select statement gives you?

SjoerdVerweij : no need to be rude.

son_robin: please elaborate on what you need

*Total size of log and data files for current database
*Total size of log and data files for all databases
*The above divided by Total size left on disc
*Other
Yes.

If you can right click on the database from the enterprise manager (SQL SEerver 2000) and click on properties, it will give size and space available.

SjoerdVerweij, I know your query can return size (current size). But I want to get the space avilable or Total size. Got it??

Thanks SNilsson!

I thought it was a fairly mild response to an inaccurate and mildly accusatory statement. No need to be belligerent.

(Sorry, but I just had the worst lunch in the history of lunches and the indigestion is doing terrible things to my mood).
Okay, what is the difference between current size and total size?
Total size is is the size allocated when you create the database. Current size is the size occupied by the database at present. The space available shows how much size is left so that we can dump data into it.

I need to write a code in the front end to verify if the dtatabse is nearing its available total size and if it does then alert the system admin

Hope this clarification helps.

Thanks,
Robinson.
I see. One more question though: why not set the database to grow automatically?
ASKER CERTIFIED SOLUTION
Avatar of arbert
arbert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial