MS SQL Synchronize Login

If you restore a database and the sql login already exists on your system versus the source system, this can cause SID (Security Identifier) mismatches.

The solution is to run a query to reassociate a login for a particular foreign source database which you restored and has the same sql login, but with a different internal SID to the current database server same named sql login

This command

sp_change_users_login 'Update_One', 'TheUserName', 'TheUserName'