dbo not found in users collection

  • trying to add sa as database owner to new database. Recieved following error:

    Error 21776:[SQL-DMO]The name 'dbo' was not found in the Users collection. If the name is a qualified name, use [] to separate various parts of the name.

    Could not find any further info in BOL.

    Help!

  • Thanks to Patrick Gallucci via the mssqldba@lazydba.com listserv! Here's the fix:

    This is because there is no DBO assigned to the db that is recognized on

    the server.. Create a new account and add it as dbo to the db, then

    change then owner to sa...

    Example below

    use MASTER

    go

    exec sp_revokedbaccess 'ACCOUNT'

    exec sp_revokelogin 'DOMAIN\ACCOUNT'

    go

    use DATABASE

    go

    exec sp_revokedbaccess 'ACCOUNT'

    exec sp_revokelogin 'DOMAIN\ACCOUNT'

    exec sp_grant login 'DOMAIN\ACCOUNT'

    exec sp_defaultdb 'DOMAIN\ACCOUNT','DATABASE'

    exec sp_grantdbaccess 'DOMAIN\ACCOUNT', 'ACCOUNT'

    go

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply