Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Urgent:Changing Login name of a DB user

Posted on 2006-06-11
Medium Priority
Last Modified: 2008-01-09
Hey experts,

  In the list of users of a DB, I have the following:
  dbo (with Login Name ecmp)
  ecmp (with no Login Name)
  I want to change it to become as follows:
  dbo (with Login Name sa)
  ecmp (with Login Name ecmp)
  any help on the fastest way to do that?
Question by:mte01
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 2000 total points
ID: 16881816

exec sp_change_users_login 'Update_One' , 'dbo', 'sa'
exec sp_change_users_login 'Update_One' , 'ecmp', 'ecmp'

Author Comment

ID: 16881881

I fixed it after using the AutoFix option; There was an error in using yours regarding the sa login:
Terminating this procedure. 'sa' is a forbidden value for the login name parameter in this procedure.

It's amazing how you know all these internal stored procedures...many thanks for your super help!!

Author Comment

ID: 16881884
Apparently I need to do the change on user dbo too.....it's a bit urgent..any help how to do that??
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16881910
>Terminating this procedure. 'sa' is a forbidden value for the login name parameter in this procedure.
interesting. I never tried it on dbo/sa, so good to know.

>Apparently I need to do the change on user dbo too.....it's a bit urgent..any help how to do that??
this looks like you made ecmp user the dbowner.
I know that with sp_changedbowner you can change the ownership to another user of the database, which makes that one dbo, but I don't know how to make the dbo as such.
possibly, this might work:
* use sp_changedbowner to make ecmp user the owner
* drop the dbo
* grant sa login permissions to the database
* use sp_changedbowner to make that new user the owner of the db

Author Comment

ID: 16881933
I solved it by detaching the DB, re-attaching it with sa the owner, then doing the same thing again with ecmp being the owner (which I want it to be), and it did the trick!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question