Sunday, March 25, 2012

ALTER USER WITH LOGIN

What's the syntax to use the ALTER USER command to remap an orphaned user to
an existing login in SS2005?
It should be:
ALTER USER user_name WITH LOGIN = login_name
Replace the <user_name> and <login_name> accordingly with the orphaned user
and the existing login.
HTH,
Plamen Ratchev
http://www.SQLStudio.com
|||Do you know about the "sp_change_users_login" sp?
You can check it out from the following link if you don't.
http://technet.microsoft.com/en-us/library/ms174378.aspx
Ekrem ?nsoy
"ken s" <kens@.discussions.microsoft.com> wrote in message
news:8C6629E3-C7D7-467A-A54E-0D9DC5F480F9@.microsoft.com...
> What's the syntax to use the ALTER USER command to remap an orphaned user
> to
> an existing login in SS2005?
|||The only catch is it that sp_change_users_login works only for SQL Server
logins, while ALTER USER WITH LOGIN supports both SQL Server and Windows
logins.
Plamen Ratchev
http://www.SQLStudio.com
|||Yup, I already know that but Ken did not mention this need. I did not need
to mentioned this catch because it's already declared in the link I gave.
Alternative is alternative.
Ekrem nsoy
"Plamen Ratchev" <Plamen@.SQLStudio.com> wrote in message
news:15E92A6A-2E39-40B8-A9F9-0F90007BB3D7@.microsoft.com...
> The only catch is it that sp_change_users_login works only for SQL Server
> logins, while ALTER USER WITH LOGIN supports both SQL Server and Windows
> logins.
> Plamen Ratchev
> http://www.SQLStudio.com
|||That worked fine on my development machine, but on the server I get this error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'psts_web'.
Here's the code I tried to run:
ALTER USER psts_web WITH LOGIN psts_web
"psts_web" is the user name and the login name and they both exist in the db.
Thanks
/Ken
|||Hi Ken,
You used incorrect syntax. It should be:
ALTER USER psts_web WITH LOGIN = psts_web
Note the part "... LOGIN = psts_web", you were missing the "=".
HTH,
Plamen Ratchev
http://www.SQLStudio.com

No comments:

Post a Comment