Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change Database Owner

Posted on 2013-11-07
5
Medium Priority
?
443 Views
Last Modified: 2013-11-13
I recently upgraded from SQL Server 2000 to SQL Server 2008.  To do this, I created new databases in 2008, then restored the 2000 bak file to the 2008 database.  All seems to be working just fine for about a week now.  

I need to change the length of a varchar field from 50 to 200 characters.  Should be simple enough.  However, I'm getting a message stating that the change can't be made because there is no owner assigned to the database.  I've tried changing the owner using:

exec sp_changedbowner 'netadmin'

I am getting this message:
Msg 15110, Level 16, State 1, Line 1
The proposed new database owner is already a user or aliased in the database.

It doesn't make sense to me that I can only assign a database owner that does NOT exist.  What am I missing here?

Thanks,

Linda
0
Comment
Question by:VMKuser
5 Comments
 
LVL 5

Expert Comment

by:dannygonzalez09
ID: 39632266
try recreating the user

USE MyDB
GO
SP_DROPUSER ‘test_user’ – Dropping test_user from the user database
GO
SP_CHANGEDBOWNER ‘test_user’ – Changing the OWNER of the database

Check this Kb article
http://support.microsoft.com/kb/866052
0
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 39632375
Did you re-sync any/all "orphaned" users in that db?

In particular, we need to make sure that user 'netadmin' is not orphaned:

USE <your_db_name>
EXEC sp_change_users_login 'UPDATE_ONE', 'netadmin', 'netadmin'

Then see if it's now accurately shown as the (already existing) owner:

EXEC sp_helpuser
0
 
LVL 27

Accepted Solution

by:
Zberteoc earned 1500 total points
ID: 39632391
Change the owner to sa like this:

ALTER AUTHORIZATION ON DATABASE::MyDatabase TO sa
0
 

Author Comment

by:VMKuser
ID: 39632636
None of these worked when I was trying to change the dbowner to 'netadmin', an administrator account.  But when I tried changing to 'sa', zberteoc's suggestion worked.  So I guess 'sa' will remain the owner of the db.  Works for me.

Thanks, everyone.
0
 
LVL 27

Expert Comment

by:Zberteoc
ID: 39633477
Another thing you can do is to use the UI from Management Studio. You should have MS 2008 after upgrade. To change the owner:

1. Right click on the database name
2. Click Properties
3. On left panel choose Files
4. In the right panel you can change the Owner by either typing the whole name if you know it or you can search it on your domain if you click on ...(domain users)

At this point you can apply the changes in 2 ways:

1. Click OK
2. Click on the Script icon in the top left corner, which will generate the SQL script in a new query window and you can run it from there.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 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