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 by  Santosh Kumar Singh
 1301  View(s)
Ratings:
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.

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: I want to restore a database .bak file(Tasks->Restore->Database; after I select from device and select file

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!