Urgent:Changing Login name of a DB user

Posted on 2006-06-11
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
  • 3
  • 2
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 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'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'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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

730 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