Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2007
    Posts
    8

    Unanswered: Exclusive access could not be obtained because the database is in use

    Hi!

    We're using a backup with sql server agent when doing a backup / restore
    procedure. In some cases I get the following error when the restore job
    fails:

    Executed as user: DOMAIN\Administrator. Exclusive access could not be
    obtained because the database is in use. [SQLSTATE 42000] (Error 3101)
    RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013).
    The step failed.

    Is it related to unhandled lock? I've resolved this by restarting the sql
    server. But is there a way to avoid such issues?
    One more question. Is it OK to backup/restore database while there're users
    connected? Or I can do only backup?

  2. #2
    Join Date
    Feb 2004
    Location
    Bangalore, India
    Posts
    250
    The DB must not be in use during the restore operation.
    Cheers....

    baburajv

  3. #3
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Preceed the backup step with the TSQL step that contains the following:

    alter database <db_name> set single_user with rollback immediate

    Then add another TSQL step after the backup:

    alter database <db_name> set multi_user
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •