Search code examples
sql-serverlocaldbdatabase-restore

Cannot restore database with .mdf extension in sql server


I have back-up my database from LocalDB server which is .mdf file:

C:\THESIS - SOURCE CODE\SIS-JEN\SIS\APP_DATA\SIS_DB.MDF

and it was successfully backed-up with an extension of .bak:

C:\THESIS - SOURCE CODE\SIS-JEN\SIS\APP_DATA\SIS_DB.MDF.bak

Now, I want to restore this back-up file to the new server(my pc/server), but I cannot successfully restore using the .bak file:

C:\THESIS - SOURCE CODE\SIS-JEN\SIS\APP_DATA\SIS_DB.MDF.bak

I've got this error:

Restore of database 'C:\THESIS-SOURCE CODE\SIS-JEN\SIS\APP_DATA\SIS.DB.MDF' failed

enter image description here Can anybody help me to fix this error?


Solution

  • Check about RESTORE statement -

    USE [master]
    GO
    
    RESTORE DATABASE [SIS_DB] FROM DISK = N'D:\SIS_DB.bak'
        WITH FILE = 1,
        MOVE N'SIS_DB' TO N'D:\SIS_DB.mdf',
        MOVE N'SIS_DB_log' TO N'D:\SIS_DB_log.ldf', NOUNLOAD