Complete a Server Assessment – File Group Information

Below you will find the code to get information about the filegroups for all databases.  Simply select the text and copy to the Clipboard.

CREATE TABLE #fg ( DBName VARCHAR(128)
, name sysname
, IsDefault BIT
, IsReadOnly BIT)
EXEC master.sys.sp_MSforeachdb
use [?]
insert into #fg select db_name() ,name, is_default, is_read_only from sys.filegroups ‘
SELECT  CONVERT(VARCHAR(50),DBName) AS ‘DBName’
, CONVERT(VARCHAR(50),name) AS ‘Name’
, IsDefault
, IsReadOnly
FROM #fg

DROP TABLE #fg

This code was written using the Microsoft SQL Server documentation.  If you find that this code was copied from else where, please let me know so I can give proper credit.