restore database from 2 mdf files

  • hi all

    i hav one database backup file which contain 2 mdf and 2 ldf file. now i want to restore it with 1 mdf & 1 ldf file, means i want to merge both mdf files into one. help me pls

    thanx

    nitin

  • nitin jain (9/4/2009)


    hi all

    i hav one database backup file which contain 2 mdf and 2 ldf file. now i want to restore it with 1 mdf & 1 ldf file, means i want to merge both mdf files into one. help me pls

    thanx

    nitin

    Are both files part of primary filegroup OR the 2nd mdf file is in a different filegroup?



    Pradeep Singh

  • thanx pradeep,

    both mdf files having same primary filegroup

    nitin

  • nitin jain (9/4/2009)


    thanx pradeep,

    both mdf files having same primary filegroup

    nitin

    In this case you can use emplyfile parameter in dbcc shrinkfile

    Use Mydb

    dbcc shrinkfile(SecondaryFile, emptyfile)

    --2nd file has been emptied, now remove that file from the database

    Alter database mydb

    remove file SecondaryFile

    Refer : example D at http://msdn.microsoft.com/en-us/library/ms189493.aspx%5B/url%5D



    Pradeep Singh

  • SecondaryFile is the logical name of the 2nd file in the primary filegroup which you want to remove.



    Pradeep Singh

  • nitin jain (9/4/2009)


    i hav one database backup file which contain 2 mdf and 2 ldf file. now i want to restore it with 1 mdf & 1 ldf file, means i want to merge both mdf files into one.

    Can't be done as part of the restore. You'll have to restore first and then merge and drop the extra files. A restore puts the DB back into the state it was at the time of backup, same number of files, same distribution of data.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 6 posts - 1 through 5 (of 5 total)

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