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

Microsoft SQL Server 2012 Recommendation

Microsoft SQL Server 2012 Express is a feature-rich yet FREE data management system. It is far...

Comparison of MS SQL Server 2008 V/s. MS SQL Server 2012

Following is a feature comparison between MS SQL Server 2008 and MS SQL Server 2012. We don't...

Choosing Between SQL Server 2012 and SQL Server 2014

If you are running SQL Server 2008 R2, you might be looking to upgrade your SQL server to...

How do I close active connections in MSSQL Server?

Please refer to the following steps to close active connections in the MS SQL server. Open the...

How to check active connections on your MS-SQL Database ?

To check active database connection in the MS SQL server please follow the below steps. Open...

  • 0 Users Found This Useful

Was this answer helpful?