Home > DeveloperSection > Forums > I want to restore a database .bak file(Tasks->Restore->Database; after I select from device and select file
Santosh Kumar Singh

Total Post:8

Points:56
Posted on    December-18-2014 4:41 AM

 Database SQL Server 2012 
Ratings:


 1 Reply(s)
 936  View(s)
Rate this:

The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\XXXXXX.mdf'. Msg 3156, Level 16, State 8, Server XXXX, Line 2



Friends you have solution, please share with me.

Thanks.



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    December-19-2014 11:22 PM

You could use something like the following script. It restores a database from the filesystem, and it overwrites the existing database with the name of "MyDB", moving the files to new locations of your choice in the process.

RESTORE DATABASE

    MyDB

FROM DISK = '\\MyShare\MyBackup.bak'

WITH

    MOVE 'DataFile' TO 'D:\myNewDBLocation\DataFile.mdf',

    MOVE 'LogFile' TO 'E:\\myNewDBLocation\LogFile.ldf'

, REPLACE

You can find out the name of the llogical files (in the above, those are called DataFile and LogFileby running the following:

RESTORE FILELISTONLY

FROM DISK = '\\MyShare\MyBackup.bak'

Additional information about various options and parameters:

 


Modified On Dec-19-2014 11:23:31 PM

Don't want to miss updates? Please click the below button!

Follow MindStick