Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Backup and Restore of a user's default database

Author  Topic 

cornelius
Starting Member

11 Posts

Posted - 2007-05-17 : 13:08:04
Hello.
I am trying to perform a backup and restore of a user's default database. the user- "myuser", was created with a default database. I have backed the user database and tried to restore it in different ways and I always get the same error when trying to connect with the user after restore:

"Cannot open user default database.Login failed (error 4064)".

It happens if I don't delete the user before restoring the database.

If I try to delete the user before restore and create it afterwards, when I try to set the default user database to the same database I get the error:

"user, group or role 'myuser' already exist in the database"

And when I try to delete the user from the restored database (in order to recreate it) I cannot, because the user's schema is connected to objects in the database.

Can anyone help?... How do I restore??
Thanx,
Nili.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-05-17 : 13:16:58
You need to unorphan the account via sp_change_users_login.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

cornelius
Starting Member

11 Posts

Posted - 2007-05-20 : 03:50:44
Thank you Tara!
I executed the procedure and it solved my problem! Finally..
Go to Top of Page
   

- Advertisement -