Checking database file sizes without a GUI

In: SQL Server


19 Aug 2008

Here’s a quick little statement you can use to verify the size and growth settings for a SQL Server database. It doesn’t spell everything out for you, but if you’re aware of some common conventions (-1 = unlimited, 0 = no growth), it’s a fast and easy way to verify settings before issuing your ALTER DATABASE command. The filename is commented out by default, but provided just-in-case.

SELECT
	  DB_NAME() [DATABASE]
	, name [Logical Name]
	, CEILING(SIZE/128.0) [SIZE (MB)]
	, CASE maxsize WHEN -1 THEN maxsize ELSE CEILING(maxsize/128.0) END [MaxSize (MB)]
	, CASE WHEN (status & 0x100000) = 0 THEN CEILING(growth/128.0) ELSE growth END [Growth]
	, CASE WHEN (status & 0x100000) = 0 THEN 'MB' ELSE '%' END [% or MB]
	--, filename
FROM
	sysfiles

Some example output:

Database	Logical Name		Size (MB)	MaxSize (MB)	Growth	% or MB
ReportServer	ReportServer		18		-1		1	MB
ReportServer	ReportServer_log	177		2097152		10	%

And an image from SSMS to verify:
File growth in GUI

  • Share/Bookmark

Comment Form

  • Yushe » Blog Archive » Conectar SQL Server con MySql: [...] Disclaimer: El árticulo arriba no es mio, es solo una traducción parcial del árticulo aqui [...]
  • Nick: Here is an extensive how to on sharing folders with Windows 7. http://www.ilertech.com/2010/09/shar [...]
  • dushyant kayarkar: I attempted to update my password on Ubuntu today and encountered a strange error. I thought I’d d [...]
  • Prakash - Savvysoft Technologies: USE master GO -- To use named parameters: Add linked server in the source (Local machine - eg: Mac [...]
  • Mike: Doh! The inprocess flag was killing me. Thanks. [...]


This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.