0

I must restore/create a db (in a new instance) in one file(mdf) from a backup of the same but with two files of data (mdf and ndf)

How can I do it?


This is what I try... but it did not work

    RESTORE database mydb
    FROM  DISK='\\150.10.10.12\backup\mydb.bak' 
    WITH  REPLACE, RECOVERY, 
    MOVE 'Mydb_DATOS'       TO 'F:\MSSQL\Data\Mydb.mdf', 
    MOVE 'Mydb_REGISTRO'    TO 'G:\MSSQL\LOG\Mydb_LOG.ldf'

then check the following

 RESTORE FILELISTONLY 
 DISK='\\150.10.10.12\backup\mydb.bak'

enter image description here

1 Answer 1

2

You need to include the .NDF file in your restore script.

 RESTORE DATABASE mydb
    FROM  DISK='\\150.10.10.12\backup\mydb.bak' 
    WITH  
        REPLACE
      , RECOVERY
      , MOVE 'IMAGENES_Data' TO 'F:\MSSQL\Data\Mydb.mdf'
      , MOVE 'IMAGENES'      TO 'F:\MSSQL\Data\Mydb.ndf' 
      , MOVE 'IMAGENES_Log'  TO 'G:\MSSQL\LOG\Mydb_LOG.ldf';
2
  • In the new instance i can restore all db in only file mdf? Sep 1, 2015 at 17:31
  • @diegoxfs During a restore, you cannot merge your non-MDF files into the MDF file. You could restore the database and then move your data to the MDF, empty the NDF file(s), and then drop them.
    – ooutwire
    Sep 1, 2015 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.