Posts

Showing posts from September, 2024

SQL Server – How to get sizes of all databases on a server

  To get all  database size information, we can use the  sys.master_files   catalog view in the instance. This view contains a row per file of a database for all databases. The columns of interest for retrieving database size information are: Column name Data type Description database_id int ID of the database to which this file applies. The  database_id  for the  master  database is always  1 . file_id int ID of the file within database. The primary  file_id  is always  1 . file_guid uniqueidentifier Unique identifier of the file. NULL  = Database was upgraded from an earlier version of SQL Server (Valid for SQL Server 2005 (9.x) and earlier versions). type tinyint File type: 0  = Rows 1  = Log 2  = FILESTREAM 3  = Identified for informational purposes only. Not supported. Future compatibility is not guaranteed. 4  = Full-text (Full-text catalogs earlier than SQL Server 2008 (10.0.x); full-text ca...