How to identify and fix the orphan users in MSSQL Server?

Orphaned user in MSSQL means that a user who is present at the database level but the relevant login doesn’t present on the server. This kind of user can be created when you perform database migration. 

By default, MSSQL Server login is mapped with SQL Database user. If this is not defined properly for MSSQL Server principal then the user will not be able to log in successfully for its database and this user is called an orphan user.

Please find the below SQL query to find the orphaned users in MSSQL.

USE
USER DATABASE
EXEC SP_CHANGE_USERS_LOGIN ‘REPORT’
GO

The following are the steps to fix orphaned users using ORPHANED USER SID

If there are any orphaned users, then we can create its login by using orphaned user SID.

Syntax:

USE
MASTER
CREATE LOGIN [LoginName] WITH PASSWORD = ‘[email protected]’,
SID = 0xF0C10D1C8EDFGA06435B07DAD54FFAE

Related Articles

How to take MSSQL database offline or bring it online?

Sometimes, you come across to a situations when you are required to physically move the database...

How to install MS SQL Server 2016?

Microsoft® SQL Server® 2016 is the latest version of Microsoft's relational database management...

How to Install Advanced Features on Existing Instance of MS SQL Server?

If you have chosen MS SQL Server to be installed in Windows VPS while placing an order, you'll...

How to add db_owner role to newly created users?

From Plesk version 12, MSSSQL users created from the Plesk panel will not have the db_owner...

Comparison of MS SQL Server 2014 Express Edition V/s. MS SQL Server 2014 Web Edition

Following is a brief comparison between MSSQL Server 2014 Express Edition and MSSQL Server 2014...

  • 0 Users Found This Useful

Was this answer helpful?