Saturday 3 November 2012

The backup set holds a backup of a database other than the existing database

The backup set holds a backup of a database other than the existing database.


Solution:


I have solved the Issue following the below steps.
§  Use WITH REPLACE while using the RESTORE command
§  Execute the following SQL Query

Alter Database MicrosoftDynamicsAX_model
      SET SINGLE_USER With ROLLBACK IMMEDIATE  

RESTORE DATABASE MicrosoftDynamicsAX_model
      FROM DISK = 'D:\AX2012\MicrosoftDynamicsAX_model.bak'
      WITH REPLACE




Thank you and Happy DAXing... :)


Updated Query:

ALTER DATABASE AX_IntegrationDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
RESTORE DATABASE AX_IntegrationDB
FROM DISK = 'D:\SIngu\AdrenalinSharedDB.bak'
WITH MOVE 'AX_IntegrationDB' TO 'C:\Program Files\Microsoft SQL Server\MSSQL11.DARWIN\MSSQL\DATA\AX_IntegrationDB.mdf',
MOVE 'AX_IntegrationDB_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL11.DARWIN\MSSQL\DATA\AX_IntegrationDB_log.ldf',
REPLACE





2 comments:

  1. Hi raghavendar,

    It executed correctly for model database, but for the main database it gave me the following error.

    Msg 5133, Level 16, State 1, Line 4
    Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MicrosoftDynamicsAX.mdf" failed with the operating system error 3(The system cannot find the path specified.).
    Msg 3156, Level 16, State 3, Line 4
    File 'MicrosoftDynamicsAX' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MicrosoftDynamicsAX.mdf'. Use WITH MOVE to identify a valid location for the file.
    Msg 5133, Level 16, State 1, Line 4
    Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MicrosoftDynamicsAX_log.LDF" failed with the operating system error 3(The system cannot find the path specified.).
    Msg 3156, Level 16, State 3, Line 4
    File 'MicrosoftDynamicsAX_log' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MicrosoftDynamicsAX_log.LDF'. Use WITH MOVE to identify a valid location for the file.
    Msg 3119, Level 16, State 1, Line 4
    Problems were identified while planning for the RESTORE statement. Previous messages provide details.
    Msg 3013, Level 16, State 1, Line 4
    RESTORE DATABASE is terminating abnormally.

    I am using SQL server 2012.

    Any suggestions to get ride of this issue.

    Thanks in advance,

    Arun

    ReplyDelete
    Replies
    1. Updated Query:

      ALTER DATABASE AX_IntegrationDB
      SET SINGLE_USER WITH
      ROLLBACK IMMEDIATE
      RESTORE DATABASE AX_IntegrationDB
      FROM DISK = 'D:\SIngu\AdrenalinSharedDB.bak'
      WITH MOVE 'AX_IntegrationDB' TO 'C:\Program Files\Microsoft SQL Server\MSSQL11.DARWIN\MSSQL\DATA\AX_IntegrationDB.mdf',
      MOVE 'AX_IntegrationDB_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL11.DARWIN\MSSQL\DATA\AX_IntegrationDB_log.ldf',
      REPLACE

      Delete