SQL Server Performance

How do to restore database

Discussion in 'Performance Tuning for SQL Server Replication' started by thangnc, Apr 6, 2004.

  1. thangnc New Member

    Hi all!
    When restore database, i used statement:
    USE master
    ALTER DATABASE TestDB#SDCList SET recovery bulk_logged
    RESTORE DATABASE TestDB#SDCList
    FROM DISK = N'C:program FilesHueSDCHueSdcAccountingDataBackupTestDB#SDCList 6-4-2004 10 39 31 AM.dat'

    It's error:
    Exclusive access could not be obtained because the database is in use.
    Please help me close database when Somebody is openning
    Thank!
  2. satya Moderator

    From QA run SP_WHO2 and see which process is accessing this database.
    And kill that process using KILL statement.

    Satya SKJ
    Moderator
    http://www.SQL-Server-Performance.Com/forum
    This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
  3. Luis Martin Moderator

    Another way is to change Database Properties to dbo only and after restore, back to public again.



    Luis Martin
    Moderator
    SQL-Server-Performance.com
  4. thangnc New Member

    Thank you help me!
  5. satya Moderator

    Small addition to Luis's comments :
    If any of the logins with SYSADMIN privilege uses the database, even though when you enable DBO USE only it will error and only the method is to kill those connections before restoring the database.

    Satya SKJ
    Moderator
    http://www.SQL-Server-Performance.Com/forum
    This posting is provided “AS IS” with no rights for the sake of knowledge sharing.

Share This Page