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,