I have a database that is close to filling the hard drive that it lives on. I'd like to expand the database on to another hard drive to deal with this.
I see there's a Files option in the database properties under SSMS that I could add to but I don't really want to go adding files without knowing what comes next. Do I need to add a new entry to Filegroups and then add to Files? Is the PRIMARY type only supposed to be used for the first file? If not then what is the difference between making one primary and another secondary? Once I add a file, does the DB engine automatically decide where to put data or do I have to go into my tables and specify this in some way?
Sorry if this is a duplicate. I'd be surprised if it isn't but I couldn't find another question that had these answers.
Best Answer
You can do one of two things here:
No, the PRIMARY filegroup can contain multiple data files.
Within the filegroup, SQL Server will manage the data dispersion across the data files through a proportional fill algorithm. Therefore, you will not need to manually administer where the data goes within a filegroup. But, if you create an additional filegroup with one or more data files, and you want data to live on that filegroup then you will need to explicitly state that (unless you set the new filegroup as the default filegroup).
For instance:
To find out what your default filegroup currently is:
To change the default filegroup: