Migrating SQL Server Database Logins with sp_help_revlogin
You’ve migrated your database to a new box, with no problems. You created the login that goes with this database, and all is right in the world. However, when your user goes to connect to it they get the dreaded error 18456, login failed. But wait, I created the login, right?
Not so fast there, accidental DBA. You are going to need the help of a nifty stored procedure called sp_help_revlogin. This stored procedure, provided by Microsoft in the link below, will generate a T-SQL script that will copy the logins, their passwords and their corresponding SIDs (or security identification number, which is usually the culprit here). This is also a great utility when the database has numerous users with various security levels and passwords.  Really now, who wants to write all of that down and recreate it? Even with screenshots, it can turn into a large, fat-fingering and time consuming event. Mind-numbing, I would say. Why do something manually when you can do it automagically?  Just think of all those happy logins that will not be orphaned by the dark side?
Here is also a code snippet to check for orphaned logins, for your enjoyment. Enjoy!
USE <database_name>; GO sp_change_users_login @Action='Report'; GO
Posted on December 29, 2011, in Migration, Scripting, Security and tagged change users, migration, orphan, security levels, sp_help_revlogin, sql server 2005, SQL Server 2008R2, stored procedure, T-SQL. Bookmark the permalink. 3 Comments.
I discovered your blog internet website on bing and appearance several of your early posts. Preserve up the extremely great operate. I just now additional the RSS feed to my MSN News Reader. Seeking toward reading far far more on your part down the road!… 19805
Reblogged this on SQL Swampland and commented:
The third most popular blog post for 2012! Enjoy!
Pingback: My Homepage