How to connect an existing SQL Server connection to an existing SQL Server database user with the same name

advertisements

Is there a SQL Server command to connect a user of a single database to a login for the database server of the same name?

here's the example:

Database Server - Default Instance Database: TestDB

Server Login - TestUser Existing user on TestDB - TestUser

If I try to make the TestUser login a user of the TestDB database, the "User, group, or role" already exists.

Does anybody know of an easy way to assign the user to the login?


The new way is to use ALTER USER

ALTER USER OrphanUser WITH LOGIN = correctedLoginName