Restore problem

  • Hi,

    When I restore a database I get the following error.....

    "System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use. (Microsoft.SqlServer.Smo)"

    But I restore my database at that when nobody access the database.

    However I receive the above error.

    Please help me to resolve the above error.

    Regards,

    Sunil.....

  • Do you have Reporting Services running? If so, try stopping the service.

    If Reporting Services is not running, try starting the server in single user mode.

  • also run sp_who2 to see who/what application is using your db.

    - Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Try restoring the database in single user mode

  • Hi,

    Please follow this following steps:

    1. Use sp_who2 to check for the user currently connected to the db and kill the spid accordingly, it shloud not even be in the sleeping state.

    2. Then put the database in single-user mode, so that no on else can access the db

    3. Then start restoring the database

  • Assuming that there really is 'nobody else' accessing the database, perhaps the default database for the user performing the restore is that very database you are trying to restore over.

    SQL BAK Explorer - read SQL Server backup file details without SQL Server.
    Supports backup files created with SQL Server 2005 up to SQL Server 2017.

  • Hi,

    I ran into this issue yesterday too! You do need to kill the SPIDs that are accessing the database. Use sp_who2 to find out which ones they are. Then in query window type KILL and the spid number. Kill as many spids as you need to but do not run the query yet. then type GO after you have all our KILL statements and write the restore statement after that. Then run the whole thing together so this way nothing has time to establish another connection between the time you killed the spids and when the restore operation takes place... it should look something like this:

    KILL 66

    KILL 56

    GO

    RESTORE DATABASE adventureworks FROM .... (rest of restore statement)

    GO

    -Eric

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply