x
login about faq Site discussion (meta-askssc)

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 '09 at 01:54 PM in Default

Kev Riley gravatar image

Kev Riley ♦♦
46.1k 38 43 69

(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

ALTER USER mary
WITH LOGIN = mary
more ▼

answered Oct 12 '09 at 01:59 PM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 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 '09 at 04:15 PM Kev Riley ♦♦

Definately helped me figure out what I needed to change in a dynamic routine. Thanks.

Mar 16 '10 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 '09 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 '09 at 02:09 PM Matt Whitfield ♦♦

You're correct. I'm still on RTM BOL after rebuilding my workstation. Thanks.

Oct 12 '09 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

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1601
x914
x5

asked: Oct 12 '09 at 01:54 PM

Seen: 2978 times

Last Updated: Oct 15 '09 at 05:57 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.