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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: