Addidng a Data File

  • Hi

    Is there a way to add a data file to a database and then balance the data over the two files?

    Thanks in Advance

  • Didn't quiet understand what is it that you are trying to achieve, but no, database can only have 1 primary data file.

  • A database can only have one primary data file but it can have several secondary datafiles. if you look in BOL for Physical Database Files and Filegroups it should give you all the information you need for adding secondary datafiles

    Hope this helps

    Gethyn Elliswww.gethynellis.com

  • You can have multiple filegroups and multiple datafiles in a filegroup, but you must have a filegroup called primary with at least one datafile.

    The first datafile has the extension of .mdf, the rest .ndf (but actually, it doesn't matter which extension you give it's more a recommendation)

    In order to balance your data over multiple datafiles try this:

    - create a new filegroup with ## datafiles, all the same (small) size, all the same growth options

    - move tables to this new filegroup (some wonderful scripts are available on the internet). rebuild clustered indexes with new filegroup (see "storage" option in management studio) will move the table.

    - Notice that alle the new files will grow (almost) equally

    - shrink original filegroup datafiles (if primary), or delete filegroup

    Wilfred
    The best things in life are the simple things

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

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