Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

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

For 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 DB user to the server login?

1 Answer

0 votes
by (40.7k points)

For SQL 2008 onwards, try using ALTER USER like this:

ALTER USER OrphanUser WITH LOGIN = correctedLoginName;

Related questions

Browse Categories

...