SQL Server Login and SQL Server Database user

  • 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.

  • 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.

  • Thak you.

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

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