-1

What is the correct way to fix orphan user:

sp_change_users_login @Action='update_one', 
@UserNamePattern='TestUser1', 
@LoginName='TestUser1'

Or

ALTER USER TestUser1 WITH LOGIN=TestUser1

Both fix the orphan user.

variable
  • 3,590
  • 4
  • 37
  • 100

1 Answers1

4

The documentation states about sp_change_users_login:

This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER USER instead.

Link https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-change-users-login-transact-sql

Peter
  • 2,530
  • 2
  • 6
  • 20