This post has been migrated from www.experimentsincode.com, 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;
GO
EXEC sp_change_users_login 'Auto_Fix', 'username', NULL, 'password';
GO
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.