Thursday, October 4, 2007

Orphaned users issue in SQL server

If you move a SQL server database from one server to another, user defined logins cause orphaned users. For example, you have a login in server A and defined it as user in its subsequent databases. When you move the database to another server, server B, the user still exist in the database and not in the server. You can create a new login the same as the one that exist on server B. So far there is no problems. As soon as you want to assign the user to the database, you will get error message since the user already is available in the database.


Here is how to fix this problem:


USE DatabaseName
go
exec sp_change_users_login 'Auto_Fix', 'UserName'
go



DatabaseName and UserName are placeholders.

No comments: