We help IT Professionals succeed at work.

SQL Server 2012 - exec sp_change_users_login 'update_one' error - The User name '' is absent or invalid.

Zack
Zack asked
on
1,469 Views
Last Modified: 2017-05-25
Hi EE,

I am running SQL Server 2012 HAG group, and I am trying to restore a database to it. However when I execute the command on the primary replica:

exec sp_change_users_login 'update_one', 'topcatcleaning', 'topcatcleaning'

I get the following error:

Msg 15291, Level 16, State 1, Procedure sp_change_users_login, Line 114
Terminating this procedure. The User name 'topcatcleaning' is absent or invalid.

I checked the login exists in the HAG instance and the Primary replica, see screenshots, so I am unsure what to do from here.

Any assistance is appreciated.

Thank you.
TopcatLogin-HAG-Instance.PNG
TopcatLogin-Primary-Replica.PNG
Comment
Watch Question

DBA Freelancer
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
ZackGeneral IT Goto Guy

Author

Commented:
Hi Jason,

Tried using that command ALTER USER topcatcleaning WITH LOGIN = topcatcleaning the error message I got was:

Msg 15151, Level 16, State 1, Line 1
Cannot alter the user 'topcatcleaning', because it does not exist or you do not have permission.

I do have admin access to the SQL instances.

Even more strangely though when I run this command:

SELECT DP.sid,DP.name user_name, SP.name login_name
FROM sys.database_principals AS DP
LEFT JOIN sys.server_principals AS SP
ON DP.sid = SP.sid
WHERE DP.name Like '%topcat%'

Open in new window


Nothing appears tried running against the Primary Node Replica and HAG instance.

How do I troubleshoot further?

Thank you.
Vitor MontalvãoIT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
ZackGeneral IT Goto Guy

Author

Commented:
Hi Vitor,

Nothing at all.

I am thinking of just dropping the users from the Primary Replica and recreating from scratch.

I will let you know how I go.

Thank you.
Vitor MontalvãoIT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
If nothing has been returned that means no user needs to be fixed.
Why were you ran that command in the first place?
ZackGeneral IT Goto Guy

Author

Commented:
Thank you for your assistance I worked out what the issue was. When I restored the database onto the Primary Replica and checked to see if the user (topcatcleaning) had been pulled across and appeared in the HAG which it did however when I ran the exec script I received that error. Removing the user from the Primary Replica then recreating the user setting the user as the db owner and running the exec script fixed the issue.
Vitor MontalvãoIT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Still don't understand why you need to recreate the user if it was already there.
ZackGeneral IT Goto Guy

Author

Commented:
Hi Vitor,

No idea myself, if it occurs again I will repost.

Thank you.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.