I've been looking into a bunch of options on how to tackle issue of running out of space
The MDF file is currently on D drive (log file on different drive), I have an new empty E drive that I would like to start using
Based on what i've been told/ read I need to add a file on the E drive, and then run an Alter database command to add this file to the existing file group?
Then sql server will automatically see there is a lot of free space on the E drive and start saving data there?
My questions are
1) is the above correct?
2) what are the scripts to run to add the new file to the filegroup
3) do i need to tell sql server to stop saving data to the old D drive (as its almost full)
Best Answer
is the above correct?
Sort of. Adding file and Alter database goes together. Based on what you said I am assuming you only have one filegroup at this time which is called primary.
what are the scripts to run to add the new file to the filegroup
Sample tsql you need to run (copied from books online)
I highly encourage you to read this:
do i need to tell sql server to stop saving data to the old D drive (as its almost full)
You do NOT need to tell SQL Server to stop saving data to the old D drive. Because of something called
Proportional fill algorithm
.Ref: File and Filegroup Fill Strategy
Read more about this here.