USE [master] GO CREATE LOGIN [MyUser] WITH PASSWORD=N'MyPassword', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF GO USE [MyDatabase] GO exec sp_change_users_login @Action='Update_One', @UserNamePattern = 'MyUser', @LoginName ='MyUser' GO