Thursday, January 7, 2010

orphan childs in tsql

Sometimes when we restore a db we include a user on it and it might be as well available at the server we are restoring. Sometimes the user stays orphan so you can't access the database even if you have the same user as the login on the server. Here's a quick workaround for it.

to see wich users are orphan:
sp_change_users_login @Action='Report';

to perform the action:

sp_change_users_login @Action='update_one', @UserNamePattern='',
@LoginName='';

hope this helps .

No comments: