Avatar of gromul
gromul
 asked on

SQL query to get database size

Is there a SQL query to get database size?

Thanks
Microsoft SQL ServerMicrosoft SQL Server 2005SQL

Avatar of undefined
Last Comment
Hemantgiri S. Goswami

8/22/2022 - Mon
David Todd

Hi,

If it is SQL 2000 then select *
from sysfiles

If it is SQL 2005 then select *
from sys.database_files

Look up either sysfiles or sys.database_files in the appropriate BOL, and you will find a flag that marks the file as a log file or a database file, and how to interprit the size field, which iirc is in 8k pages.

Regards
  David
ASKER CERTIFIED SOLUTION
Hemantgiri S. Goswami

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23