This post has been migrated from, we apologise if some of the images or content is missing

This post has been migrated, original date 23 Oct 2009 I am noting this here because I use it all the time. I allows you to map the user login back to the DB when you restore the DB from when machine to another.
USE databaseName;
EXEC sp_change_users_login 'Auto_Fix', 'username', NULL, 'password';
If the user already has a logon to the SQL box then it will just link the database user to that login, otherwise it creates a new user with the username and password specified.