sql-serverdatabasemovefilegroup

Move file-group to a different database


Is it possible to move SQL Server file-group from one database to another one on the same server ?

If no , is there any work around?


Solution

  • You cannot do it.

    If you want to restore FG1 of db1 to another database db2, you should at least restore PRIMARY filegroup of db1 with move. And this will effectively overwrite PRIMARY FG of db2.

    From this moment db2 will know nothing about what it was. It will know that it has all the files of db1.

    So this is the same as to restore to a new non-existing database.

    Summary.

    You can restore PRIMARY + some other FG, but this always be a database with the structure that db1 had, with only difference that not all FG are online.