New database file - same filegrgoup

  • Hi

    I have an issue.

    I have a 300gb database with 10 datafiles. I created the new file on a different volume since the other volume is low on diskspace. The last file (DB_File_09.NDF) has max size 50gb and only 17gb left on disk. The new file (DB_FILE10.NDF) is on the new volume.

    Question 1:

    How can I get SQL to write to the new datafile (10.NDF)? And, can I do this "on the fly".

    Question 2:

    The new file is on the Primary filegroup and it should have been in a "Data Filegrup 1". Can I move the file into the other filegroup? Does it mean downtime for the db?

    Regards

  • Hi,

    the reply to your first question:

    SQL Server writes data to database file proportionally. No action is required.

  • If the new file is in the same filegroup, SQL Server will automatically split new extents written across both files. If you only want it to write to the new file, you can set the maximum size of the old file to it's current size, so that new extents will only go to the new file.

    If the file was in a different filegroup, then only tables and indexes created in that separate filegroup would have their new extents written to that file. I don't think there's a way to change an existing file's filegroup, because that could split an object across multiple file groups. If you need to change, then you'll have to create a new file and then alter the indexes and tables to move them to the new filegroup.

  • Thanks Chris

    That worked well for me.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply