Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

user mapped as dbo Expand / Collapse
Author
Message
Posted Tuesday, August 14, 2012 7:13 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, December 3, 2014 9:42 AM
Points: 40, Visits: 580
hi,

we are trying to drop a login that happens to be mapped/aliased as 'dbo'.
it is not the owner of the db.

so in the db itself i don't see that login name, only the user 'dbo'.
how can i remove the login mapping to the database without affecting the dbo schema?
this is sql server 2008.


thank you
Post #1345103
Posted Tuesday, August 14, 2012 11:58 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:20 AM
Points: 6,752, Visits: 14,400
Initially I would have said the login owns the database, double check and confirm this is not the case.

Has this database come from sql2000 at some point?


-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1345135
Posted Wednesday, August 15, 2012 3:10 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 4:08 AM
Points: 547, Visits: 261
If I understand the question correctly you have to transfer the ownership to another login before you drop the login:

USE [Your database]
GO
ALTER AUTHORIZATION ON SCHEMA::[dbo] TO [Another login]
GO

Post #1345179
Posted Wednesday, August 15, 2012 12:37 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 8:51 PM
Points: 7,140, Visits: 12,763
In 2005 and above you cannot remap the dbo user to a login other than sa, and you cannot drop sa.

I too would like to know if this was once a SQL 2000 database.

What does this return?

USE [your_database];
GO
SELECT SUSER_NAME(principal_id)
FROM sys.database_principals
WHERE name = 'dbo';
GO



__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1345464
Posted Wednesday, August 15, 2012 1:03 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, December 3, 2014 9:42 AM
Points: 40, Visits: 580
unfortunately i don't know the history of this db.

i was trying to recreate this scenario on a test server but i was unable to map/alias a user as dbo since that account exists in all of the dbs (sql 2008), so i too assume that the problem db may have been upgraded from older versions.

transferring dbo schema ownership as suggested above is also an option, and i wanted to transfer it to a 'dbo' user account as this seems to be the sql 2008 standard, but this user account is already aliased as the dbo, so i'm looking for a way to unmap it.

i'm looking at trying drop alias but don't want to risk losing the dbo schema.

Post #1345491
Posted Wednesday, August 15, 2012 1:16 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 8:51 PM
Points: 7,140, Visits: 12,763
sage8 (8/15/2012)
unfortunately i don't know the history of this db.

What is the value of dbi_createVersion when you run this? The number will reveal on which version of SQL Server the database was originally created.

DBCC TRACEON (3604);
GO
DBCC DBINFO ('your_database');
GO

i was trying to recreate this scenario on a test server but i was unable to map/alias a user as dbo since that account exists in all of the dbs (sql 2008), so i too assume that the problem db may have been upgraded from older versions.

sa is mapped to dbo and you cannot change that in SQL 2005 and above, and a user can only be mapped to one login.

transferring dbo schema ownership as suggested above is also an option, and i wanted to transfer it to a 'dbo' user account as this seems to be the sql 2008 standard, but this user account is already aliased as the dbo, so i'm looking for a way to unmap it.

i'm looking at trying drop alias but don't want to risk losing the dbo schema.

You cannot drop the dbo user.

What was the result of the query in my previous post?


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1345499
Posted Thursday, August 16, 2012 3:58 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 8:51 PM
Points: 7,140, Visits: 12,763
How is it going?

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1346282
Posted Thursday, August 16, 2012 5:44 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:20 AM
Points: 6,752, Visits: 14,400
Correct you can't drop the user, you change the mapping.

-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs"
Post #1346295
Posted Thursday, August 16, 2012 9:19 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 8:51 PM
Points: 7,140, Visits: 12,763
Perry Whittle (8/16/2012)
Correct you can't drop the user, you change the mapping.

You cannot change the login mapped to the dbo user either...at least I could not on 2005, 2008 R2 or 2012.

Issuing this:

USE [SomeDatabase];
ALTER USER [dbo] WITH LOGIN = [SomeLogin];

On all three versions I get this:

Msg 15150, Level 16, State 1, Line 1
Cannot alter the user 'dbo'.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1346320
Posted Monday, August 20, 2012 4:11 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, December 3, 2014 9:42 AM
Points: 40, Visits: 580
The result for:
USE [your_database];
GO
SELECT SUSER_NAME(principal_id)
FROM sys.database_principals
WHERE name = 'dbo';
GO

is 'sa'
Post #1347058
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse