Skip to content

Instantly share code, notes, and snippets.

@jmelosegui
Created June 16, 2017 13:01
Show Gist options
  • Save jmelosegui/909e6f742819a11998a2d7dab95ef940 to your computer and use it in GitHub Desktop.
Save jmelosegui/909e6f742819a11998a2d7dab95ef940 to your computer and use it in GitHub Desktop.
-- Detect
sp_change_users_login 'report'
-- Repair
SELECT 'EXEC sp_change_users_login ''Update_One'', '''+[name]+''', '''+[name]+''''
FROM sys.database_principals WHERE
type_desc='SQL_USER'
and NAME NOT IN ('dbo','guest','INFORMATION_SCHEMA','sys')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment