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

SQL Server Login and SQL Server Database user Expand / Collapse
Author
Message
Posted Wednesday, June 3, 2009 2:45 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, December 11, 2014 10:33 AM
Points: 27, Visits: 128
I restored a database dump to a new instance in my test environment. I created a login and tried to map it to an existing user in the database, however when I try to do so I get an error:

Rename failed for User 'Username', (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

User, group, or role 'user' already exists in the current database. (Microsoft SQL Server, Error: 15023).


When I try to delete the user, I also get an error:

Drop failed for User 'Username', (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138).

Please help.


Post #728527
Posted Thursday, June 4, 2009 7:24 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, August 17, 2011 7:09 AM
Points: 869, Visits: 963
Since the user owns a schema in the database, you need to find which schema it owns and change ownership, then the user can be dropped.
Post #728928
Posted Thursday, June 4, 2009 8:23 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, December 11, 2014 10:33 AM
Points: 27, Visits: 128
Thak you.
Post #728991
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse