There are several ways to get database sizes in a server. Following three system tables has the information to get database sizes.
sys.sysfiles
sys.database_files
sys.dm_db_file_space_usage
You also can use following system stored procedure.
exec sp_spaceused
However the easiest way is to use SP_HELPDB system stored procedure. Below script used that SP to get the database sizes in a server.
create table #spdbdesc
(
dbname sysname,
dbsize nvarchar(13) null,
owner sysname null,
dbid smallint primary key,
created nvarchar(11),
dbdesc nvarchar(600) null,
cmptlevel tinyint
)
INSERT INTO #spdbdesc
exec SP_HELPDB
SELECT *
FROM #spdbdesc
Sp_spaceused also includes the log space. Why the log size is important is because it can be even larger than the database itself.
ReplyDeleteBy Arthur Zubarev
Hi Arthur,
ReplyDeletedatabase size includes both data file size plus log file. even SP_HELPDB gives the same result as SP_SPACEUSED.
Jack Vamvas
ReplyDeleteI usually query the sys.master_files . It is also easy to create a report with this view
http://www.sqlserver-dba.com/2012/09/sql-server-find-the-database-file-size-and-log-file-size.html
My partner and i actually enjoy this post and the internet site all in all! Your piece of writing is really plainly composed as well as simply understandable. Your current Blog design is awesome as well! Would be awesome to know where I are able obtain it. Please maintain up the very good job. We all require far more such website owners like you on the net and much fewer spammers. Fantastic mate!
ReplyDeleteHadoop online training
Thanks for sharing with us that awesome article you have amazing blog.....
ReplyDeleteHadoop Online Training
ReplyDeleteHi, I believe your website could be having browser compatibility issues. When I take a look at your website in Safari, it looks fine however when opening in Internet Explorer, it’s got some overlapping issues. I just wanted to provide you with a quick heads up! Apart from that, wonderful blog!
SAP APO Online Training
Thank you, Raju. I will have a look.
Delete
ReplyDeletenice post and site, good work!SAP GTS Training In Hyderabad
Hadoop online training in hyderabad.All the basic and get the full knowledge of hadoop.
ReplyDeletehadoop online training in hyderbad