Login failed after restoring database on SQL Server 2008

After restoring a production database backup on SQL Server 2008, to my development machine, I got a “Login failed for user xyz”. The database user was not associated with a user and was marked as “Without login”. This happens when you do not have a login for the database user.  You can create that user but the SIDs do not match.  SQL Server provides a stored procedure to check for this scenario.

sp_change_users_login ‘report’

To correct it, use the same stored procedure with a different command.

sp_change_users_login ‘update_one’, ‘{username}’, ‘{login}’

This will make sure that your username and login have the same SID.