Tuesday 24 February 2015

How To Rename or Alter a Login name and User name in SQL Server ?

We have seen so many scenario when we need to Alter login to change a password but in very rare cases we Alter a Login means rename a Login.

Today i got one request related to create a SQL Account like VPUSER and i created the user with same name and tell that its done.

After a while he again requested can you please delete this user and create new user with the name of [VPAPPUSER] .When i asked the exact requirement why he wants to delete old user and create new one so he explained me the SQL Login account should be according of naming convention .

Then i thought i will not delete the login i will alter the login if i delete the login then i have to do lot of things after creation login like need to give all permission again.

So i Alter the Login and User as well with following command and i saved all the time .


ALTER LOGIN VPUSER WITH NAME = [VPAPPUSER];

If you will not change the User name it will work as it is but user name will be different. It will be better if naming convention should be same

ALTER USER VPUSER WITH NAME = [VPAPPUSER];




1 comment:

  1. This blog is really good just i got more information to your blog thus it is really nice and very much interesting.ya it is highlighting many important messages so that i like your message.

    Disaster recovery in the cloud

    ReplyDelete