Re: how to remove builtin\administrators

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Keith Kratochvil (sqlguy.back2u_at_comcast.net)
Date: 05/27/04


Date: Thu, 27 May 2004 15:07:29 -0500

Perhaps you have to change the owner to a new login. Have you read Books Online?

sp_changedbowner

 Transact-SQL Reference

 
sp_changedbowner
  New Information - SQL Server 2000 SP3.

Changes the owner of the current database.

Syntax
sp_changedbowner [ @loginame = ] 'login'
    [ , [ @map = ] remap_alias_flag ]

Arguments
[@loginame =] 'login'

Is the login ID of the new owner of the current database. login is sysname, with no default. login must be an already existing Microsoft® SQL ServerT login or Microsoft Windows NT® user. login cannot become the owner of the current database if it already has access to the database through an existing alias or user security account within the database. To avoid this, drop the alias or user within the current database first.

[@map =] remap_alias_flag

Is the value true or false, which indicates whether existing aliases to the old database owner (dbo) are mapped to the new owner of the current database or dropped. remap_alias_flag is varchar(5), with a default of NULL, indicating that any existing aliases to the old dbo are mapped to the new owner of the current database. false indicates that existing aliases to the old database owner are dropped.

Return Code Values
0 (success) or 1 (failure)

Remarks
After sp_changedbowner is executed, the new owner is known as the dbo user inside the database. The dbo has implied permissions to perform all activities in the database.

The owner of the master, model, or tempdb system databases cannot be changed.

To display a list of the valid login values, execute the sp_helplogins stored procedure.

Executing sp_changedbowner with only the login parameter changes database ownership to login and maps the aliases of users who were previously aliased to dbo to the new database owner.

Permissions
Only members of the sysadmin fixed server role can execute sp_changedbowner.

Examples
This example makes the user Albert the owner of the current database and maps existing aliases to the old database owner to Albert.

EXEC sp_changedbowner 'Albert'

See Also

CREATE DATABASE

sp_dropalias

sp_dropuser

sp_helpdb

sp_helplogins

System Stored Procedures

©1988-2004 Microsoft Corporation. All Rights Reserved.

-- 
Keith


Relevant Pages

  • Re: Problem with bulk load security.
    ... Then I defined the procedure using 'with execute as self'. ... As for user vs login, I don't see a syntax difference. ... database is trustworthy, you cannot get rights outside the database. ... One is to make the database trustworthy, ...
    (microsoft.public.sqlserver.security)
  • 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: not creating tables as dbo anymore ?
    ... Database Owner (dbo) ... existing user ID in the database specified by database_name. ... with the login of the current connection. ...
    (microsoft.public.sqlserver.security)
  • Re: dbo with user name in "users"
    ... be that one of them owned the database and because the login/user has been ... has something to do with not being able to validate the login. ... changing the owner to sa is usually a great ... for dbo, I get an error: "cannot insert the value NULL into column '', ...
    (microsoft.public.sqlserver.security)