Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

intermittently fail of restore in SQL server 2008 r2

$
0
0

In my java application i call the following snippet to restore the database of my system:

use master;
alter database <myDB> set single_user with rollback immediate;
restore database <myDB> from disk = "<restore file>" with recovery, replace;
alter database <myDB> set multi_user;

I need to know why this sql snippet fails intermittently with the following exception:
com.microsoft.sqlserver.jdbc.SQLServerException: Database '<myDB>' is already open and can only have one user at a time.

It seems that I fail to change the user access to multi-user after the restore.

Any help would be appreciated.

Best regards,



Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>