Last active
May 2, 2023 22:14
-
-
Save jboeke/993773 to your computer and use it in GitHub Desktop.
Fix Orphaned SQL Users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Fix orphaned users after restoring a SQL database (pre-2012 version) | |
USE YourDBName; | |
exec sp_change_users_login 'update_one', 'username', 'username'; | |
-- Fix orphaned users after restoring a SQL database (version 2012 and after) | |
USE master; | |
CREATE LOGIN username WITH PASSWORD = 'password'; | |
USE YourDBName; | |
ALTER USER username WITH LOGIN = username; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment