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

Design a site like this with WordPress.com
Get started