Link to home
Start Free TrialLog in
Avatar of Alex A
Alex A

asked on

Restoring the database: exclusive access could not be obtained

While restoring the SQL Server database, I got the message:
Exclusive access could not be obtained because the database is in use. RESTORE DATABASE is terminating abnormally.

Are there other ways of making it work except of restarting db server or dropping the database?
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LordSM
LordSM

Go To Management, Activity Monitor and kill the processes that are accessing the database. These processes are the ones that interupt the restore. This should work.

Also remember to clear your connection pool after you restore your database else you may find  'A transport-level error' . This error can be removed by
System.Data.SqlClient.SqlConnection.ClearPool(new System.Data.SqlClient.SqlConnection(string.Format(YOURCONNECTIONSTRING)));