Filegroup in MS SQL

MSSQL-Feature-Image

Filegroup is a logical group of data file.
Data file can only be a member of one file group.
Transaction log file can not be a member of file group.
Every Database have a default file group named “Primary”
We can map table to filegroup, then table will store its data to data file within the filegroup.
We can improve performance by create multi data file within filegroup because MS SQL will split data between all files account to file size.

How to view current filegroup setting:
1. Right-click suitable database object > select Properties
2. Select “Filegroups” page > View “Rows
3. Column “Files” show how many data file within this filegroup.
4. Column “Default” show which filegroup is default filegroup of this database.

How to create new filegroup via GUI:
1. Right-click suitable database object > select Properties
2. Select “Filegroups” page > Click “Add Filegroup
P.S: The above filegroup is unable to use because there are no data file within filegroup.
We need to create new data file to this filegroup.

How to remove filegroup via GUI:
1. Right-click suitable database object > select Properties
2. Select “Filegroups” page > Click “Remove
P.S: Be Careful, when you remove this filegroup, the data file within this filegroup will also be removed.

How to create new filegroup via T-SQL:

How to remove filegroup via T-SQL:

Author: Joe Chan