locked
Alter login statement meaning ?? RRS feed

  • Question

  • Hi All,

    What does the command do or what does it mean? When do we use it?

    Alter login [<loginname>] with name = [<loginname>];

    Thanks in advance.
    Sunday, September 13, 2015 6:38 PM

Answers

  • You asked the same question on SQL Server Central. For your convenience I repost my answer from that site:

    Say that you at some point run

    CREATE LOGIN Hilary WITH PASSWORD = 'sdefhsdhhh'

    And then you go on and grant permissions to this new employee. However, when this person turns up he/she is a little upset, because he/she spells the name with two l. This is when you run

    ALTER LOGIN Hilary WITH NAME = Hillary


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Proposed as answer by Kumar muppa Monday, September 14, 2015 12:57 AM
    • Marked as answer by Dan GuzmanMVP Sunday, September 20, 2015 4:27 PM
    Sunday, September 13, 2015 7:26 PM

All replies

  • Hi All,

    What does the command do or what does it mean? When do we use it?

    Alter login [<loginname>] with name = [<loginname>];

    Thanks in advance.

    Hi Samantha,

    The Alter Login command can be used for a few different things:

    • Change the password of a user
    • disable/enable a user
    • unlock a user that is locked out
    • Enforce NT password policy
    • ...

    Enable a login:

    ALTER LOGIN SampleUser ENABLE;
    

    Change a login's password:

    ALTER LOGIN SampleUser WITH PASSWORD = '19477tzsjkgh179AF@$%@%'

    I hope that helps!


    I hope you found this helpful! If you did, please vote it as helpful on the left. If it answered your question, please mark it as the answer below. :)

    • Proposed as answer by Kumar muppa Monday, September 14, 2015 12:57 AM
    Sunday, September 13, 2015 7:06 PM
  • You asked the same question on SQL Server Central. For your convenience I repost my answer from that site:

    Say that you at some point run

    CREATE LOGIN Hilary WITH PASSWORD = 'sdefhsdhhh'

    And then you go on and grant permissions to this new employee. However, when this person turns up he/she is a little upset, because he/she spells the name with two l. This is when you run

    ALTER LOGIN Hilary WITH NAME = Hillary


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Proposed as answer by Kumar muppa Monday, September 14, 2015 12:57 AM
    • Marked as answer by Dan GuzmanMVP Sunday, September 20, 2015 4:27 PM
    Sunday, September 13, 2015 7:26 PM