Re: properties owner and users owner.

From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 08/19/04


Date: Thu, 19 Aug 2004 08:09:35 -0500


'dbo' is a special database user and must exist in every database. The
database owner is the *login* that is mapped to the database 'dbo' user and
this mapping is stored in 2 places, sysdatabases and sysusers. These should
normally be the same login but can get out-of-sync in some situations, such
as a restore or attach. The query below will return the same login if the
owner entries are synchronized:

USE MyDatabase
SELECT 'sysdatabases mapping=' + SUSER_SNAME(sid)
FROM master..sysdatabases
WHERE name = DB_NAME()
UNION ALL
SELECT 'sysusers mapping=' + SUSER_SNAME(sid)
FROM sysusers
WHERE name = 'dbo'

You can execute sp_changedbowner to change or correct the mapping. If you
get error 15110, ensure the specified login is not already a database user
since a login can be mapped to only one database user at a time.

The 15110 error can also be raised due to an out-of-sync condition mentioned
above. In that case, temporarily change database ownership to a
non-conflicting login and then to the desired login like the example below:

USE MyDatabase
EXEC sp_addlogin 'TempOwner'
EXEC sp_changedbowner 'TempOwner'
EXEC sp_changedbowner 'MyDatabaseOwner'
EXEC sp_droplogin 'TempOwner'
GO

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
"ben brugman" <ben@niethier.nl> wrote in message
news:%23nqiINdhEHA.3076@tk2msftngp13.phx.gbl...
> Thanks for your time and quick response,
> see inline :
>
> "Hari Prasad" <hari_prasad_k@hotmail.com> wrote in message
> news:O2$NJIdhEHA.2052@tk2msftngp13.phx.gbl...
> > Hi,
> >
> > "Both can be same in most of the situation."
>
> I tried to make both the same.
>
> >
> > DBO - DBO is a role,  A user with a DBO role can do any activities
inside
> > the database.
> >
> > Properties section of a database there is a owner?
> >
> > He will be person who creates the database. By default he will a DBO.
This
> > owner can be changed using the procedure,
> >
> > sp_changedbowner.
>
> I cannot change the owner because :
> "
> Server: Msg 15110, Level 16, State 1, Procedure sp_changedbowner, Line 46
> The proposed new database owner is already a user in the database.
> "
>
> And in the database he is the dbo owner, so I do not think deleting that
> owner
> is wise.
>
> I still have difficulty grasping the difference between the two owners and
> still would like them to be the same.
>
> Thanks
> ben brugman
>
> >
> > Thanks
> > Hari
> > MCDBA
> >
> >
> >
> >
> > "ben brugman" <ben@niethier.nl> wrote in message
> > news:eCuSx$chEHA.4064@TK2MSFTNGP12.phx.gbl...
> > > In the properties section of a database there is a owner.
> > >
> > > Under the users of a database there is the dbo with
> > > a Login Name.
> > >
> > > What is the difference between the 'two owners' ?
> > >
> > > ben  brugman
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Accidentally dropped DBO from database
    ... That error is due to having databases where the owner (dbo) ... is mapped to a login that doesn't exist on the server. ... a user in the database" when using sp_changedbowner, ...
    (microsoft.public.sqlserver.security)
  • Re: Confused about dbo
    ... Make sure you understand the difference between login names and user names. ... database within a SQL Server instance. ... There are several ways you could have the username dbo. ... the true owner of the database. ...
    (microsoft.public.sqlserver.security)
  • Re: db_owner role in SQL 2k
    ... The owner of a database is a login, which is listed in the sysdatabases ... I try not to think of DBO as the Database Owner, but just as special, ... For anyone to use any database, their login name must have been given access ...
    (microsoft.public.sqlserver.programming)
  • Re: Login Name is missing
    ... Database ownership determines to login mapping for the 'dbo' user. ... > I see 'dbo' listed as the OWNER of all the tables. ...
    (microsoft.public.sqlserver.security)
  • Re: Who should I make the owner?
    ... Every login gets mapped to a username in every database they have access to. ... DBO is a special user name that exists in every database. ... NOT to think of DBO as meaning 'database owner' since many different logins ...
    (microsoft.public.windows.server.general)