Resolving orphaned users

With the announced deprecation of sp_change_users_login, how are we to use ALTER LOGIN to fix orphaned users, in the same way that I used to use

sp_change_users_login 'update_one','mary','mary'

Edit: Matt Whitfield pointed out I should have been talking about ALTER USER. My bad!

more ▼

asked Oct 12, 2009 at 01:54 PM in Default

Kev Riley gravatar image

Kev Riley ♦♦
54.3k 47 49 76

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

You want to use ALTER USER, rather than ALTER LOGIN.

The equivalent would be

more ▼

answered Oct 12, 2009 at 01:59 PM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

Matt: you're right I meant to write ALTER USER in the question, but had 'login' in my mind. Derren Brown eat your heart out.
Oct 12, 2009 at 04:15 PM Kev Riley ♦♦
Definately helped me figure out what I needed to change in a dynamic routine. Thanks.
Mar 16, 2010 at 12:44 PM Lynn Pettis
(comments are locked)
10|1200 characters needed characters left

From BOL, in SQL Server 2008 you can use the WITH LOGIN option of ALTER USER in order to fix an orphaned user. This functionality is also available in 2005.

more ▼

answered Oct 12, 2009 at 02:02 PM

Tim Benninghoff gravatar image

Tim Benninghoff
43 1 1 3

I'm not sure WITH LOGIN is new to 2008 - http://technet.microsoft.com/en-us/library/ms176060(SQL.90).aspx ...
Oct 12, 2009 at 02:09 PM Matt Whitfield ♦♦
You're correct. I'm still on RTM BOL after rebuilding my workstation. Thanks.
Oct 12, 2009 at 02:58 PM Tim Benninghoff
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 12, 2009 at 01:54 PM

Seen: 4373 times

Last Updated: Oct 15, 2009 at 05:57 AM