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?

How to transfer the logins and the passwords between instances of SQL Server 2005 and SQL Server 2008.

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;
 
About these ads

About SQLGator

Florida Gator and Certified SQL Server Enthusiast, Star Wars fanatic and is there anything else...oh yeah PS3! I am a geek and SQL Server DBA who dabbles with VMWare, there are other technologies greater than these? Not so fast my friend! I also love to travel to new and exotic places.

Posted on December 29, 2011, in Migration, Scripting, Security and tagged , , , , , , , , . Bookmark the permalink. 3 Comments.

  1. 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

  2. Reblogged this on SQL Swampland and commented:

    The third most popular blog post for 2012! Enjoy!

  1. Pingback: My Homepage

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,080 other followers

%d bloggers like this: