DBA Posts - How to add data file to a filegroup?

You can add new data file to an existing filegroup or you can move data files from one filegroup to another.


1- Using T-SQL
 
ALTER DATABASE SQLAge
ADD FILE
(
NAME = SQLAge2,
FILENAME = 'D:\Datafiles\SQLAge\SQLAge_2.ndf',
SIZE = 10MB,
MAXSIZE = 100MB,
FILEGROWTH = 10MB
)
TO FILEGROUP SQLAgeFG1;
GO
 
2- Using Management Studio

                   a)      Right click on the database and go to properties

b)      Click on Files
c)      Click on Add
d)     Provide logical name of the file and click on dropdown manu of filegroups
e)      Click on the new filegroup that you have created






Fig 1 - How to add a data file in a filegroup

Fig 2 - How to add a data file in a filegroup