Restore with Move

  • I inherited a database that has 5 mdf files. Four of these are in Primary file group and the last one in another file group. I can understand the advantage if these files are in different location and are part of different file group so that when the users create objects they can specify file group. Looks like who ever set this up started with the right idea but never implemented it all the way through.So I have a database file split in to five files in the same loaction.

    My question is how(if I can) can I consolidate all the 4 files into one. I appreciate your help.

    Thanks

    Sreejith

  • I found a way to do it. Hopefully this might help some one.

    1. Allow the primary file to have Unrestricted File growth.

    2. Runn DBCC to Move data from the second file. This will move it to file 1.

     DBCC SHRINKFILE ('TestMove2_Data',EMPTYFILE)

    3. Remove the file from Database

    Use Master

    go

    ALTER DATABASE TestMove REMOVE FILE 'TestMove2_Data'

    4. Keep repeating till all the files in the file group are moved to one file.

    Thanks

    Sreejith

  • Are you sure you had 5 mlf files?

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

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