Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Error Database already in use when trying to restore backup

$
0
0

Hello!

I work with the maintance and support of an ERP, so i do a lot of backups and restores.

I use Microsoft SQL Server Management Studio to do the backups, and we use SQL Server 2008.

When i want to restore a backup, i always get the error saying that the base already is in use.

So here is what i do to try to solve it:

Delete the database closing all exists connections;

Use both commands(sometimes only put single and try):

USE MASTER;
ALTER DATABASE name SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

USE MASTER;
ALTER DATABASE name SET MULTI_USER WITH ROLLBACK IMMEDIATE;

And even this command:
select spid,* from master..sysprocesses where dbid=db_id('name')

kill "nº of the process"

And even so i still get the same error. Only when i do this steps a few times it works, sometimes work at first try, but sometimes i do this like 5 times to work.

Anyone have an idea of what's happening?

Thanks!


Ps: Sorry for the bad english.



Viewing all articles
Browse latest Browse all 4871

Trending Articles