Skip to content

Instantly share code, notes, and snippets.

@axrwkr
Last active August 29, 2015 13:57
Show Gist options
  • Save axrwkr/9894101 to your computer and use it in GitHub Desktop.
Save axrwkr/9894101 to your computer and use it in GitHub Desktop.
SQL Server Autofix Logins
-- to list orphaned users
EXEC sp_change_users_login 'Report'
-- to fix a specific user (replace <user> with the user name)
EXEC sp_change_users_login 'Auto_Fix', [<user>]
-- to fix a user and create new login and password
EXEC sp_change_users_login 'Auto_Fix', [<user>], NULL, '<password>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment