Align SQL Login to User

How to re-align a SQL Login to a Database User

In SQL Server there are two distinct security level when it comes to individual users... one at the server level, the other at the database level.

If a database is restored from a different location, then despite the there being a server login and database user with the exact same name, they are different objects and do not therefore align with each other.

Instead of removing either and re-implementing, simply use the following...

ALTER USER OrphanUser WITH LOGIN = correctedLoginName;
Added 01/10/2024 12:05