Pregunta

Why I always got this Error when Restoring a backup

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

I try this but did'nt work:

use Master 
ALTER DATABASE yourdatabasename SET MULTI_USER WITH ROLLBACK IMMEDIATE;

I always have to close the ssms and open it again to restore backup. How I will avoid this error especially when I will use the backup/restore in my c# application? Do I have to change some properties of my database? I need this issue to resolve to avoid encountering it with the application which I am developing.

¿Fue útil?

Solución

Check if you have any query tab connected to this specific database. If yes, you may choose another database from the dropdown instead of closing it.

Otros consejos

Use SINGLE_USER.

ALTER DATABASE yourdatabasename SET SINGLE_USER WITH ROLLBACK IMMEDIATE
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top