x

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 ♦♦
50.6k 43 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

ALTER USER mary WITH LOGIN = mary 
more ▼

answered Oct 12 '09 at 01:59 PM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.4k 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 '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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

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

Topics:

x1816
x976
x5

asked: Oct 12 '09 at 01:54 PM

Seen: 3826 times

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