Share via


Cannot change owner for MODEL database

Question

Tuesday, October 13, 2009 2:49 AM

Here is the output for SQL 8
select name, suser_sname(sid) from master..sysdatabases
model -> NULL

And while I execute this  use model; exec sp_changedbowner 'sa'
It says

Msg 15109, Level 16, State 1, Procedure sp_changedbowner, Line 22

Cannot change the owner of the master database.

Any insights here?


yup

All replies (7)

Tuesday, October 13, 2009 3:26 AM | 1 vote

You can't change the owner for system dbs. The  sp_changedbowner stored proc contains the RULE

**if db_name() in ('master', 'model', 'tempdb')
begin
raiserror(15109,-1,-1)
return(1)
end

**BUT for your first problem "HAVING NULL VALUE IN OWNERNAME"  see this reply from RAUL GARCIA at http://social.msdn.microsoft.com/forums/en-US/sqlsecurity/thread/2efd25a0-53b3-4334-9178-2d74b8dab14f/


Thanks, Leks


Tuesday, October 13, 2009 3:54 AM

Now in my case this is showing as NULL which I believe is because of the last owner was NT Domain name & has been terminated from AD. So...yup


Tuesday, October 13, 2009 5:24 AM

What if you try to change owner using ALTER AUTHORIZATION instaed?

Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi


Tuesday, October 13, 2009 7:57 AM

Sorry I forgot to mention - this case is on SQL 2000.yup


Tuesday, October 13, 2009 8:05 AM

How about trying to restore a model database backup from any other sql 2000 machine that has sa as the owner.
Model db doesnt have any sensitive info in it about that particular instance .

I havent tried this before though !!


Thanks, Leks


Tuesday, October 13, 2009 9:46 PM | 1 vote

I tried restoring model db backup from some other server (sa as its owner) and it worked fine for me. Please try this in your dev envi before you do something on production about this.!


Thanks, Leks


Tuesday, October 27, 2009 1:51 PM

Hi,

When you rebuild the master database, the msdb database and the model database are also re-created.

BR,

JoukoK