Fix orphaned users in MSSQL
Thanks to CodeProject for this code
Run this in the Query Analyzer (make sure the right database is selected first).
Run this in the Query Analyzer (make sure the right database is selected first).
sp_change_users_login 'auto_fix', 'UserName'