Tag Archives: database id

data files and filegroups per database…


Hi All,

Use the below code to get the data files and groups information per database

 

SELECT

COUNT (*) AS [DataFiles],

COUNT (DISTINCT data_space_id) AS [Filegroups],4
SUM (size) AS [Size]

FROM sys.master_files

WHERE [type_desc] = N’ROWS’ — filter out log files/data_space_id 0

AND [database_id] > 4 — filter out system databases
AND [FILE_ID] != 65537 — filter out FILESTREAM

GROUP BY [database_id];
GO

 

Please check and let us know if you have any concerns on this.

Thanks for viewing this.

Regards,

Chaitanya

Create your own website, free on WordPress.com.Create your own website.
Start free