Drop users from database

  • Hi,

    I am trying to drop users from a specific database and getting the error below . Please help.

    TITLE: Microsoft SQL Server Management Studio

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

    Drop failed for User 'User1'. (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.5058.0+((SQL11_PCU_Main).140514-1820+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+User&LinkId=20476

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

    ADDITIONAL INFORMATION:

    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)

  • PSB (4/15/2015)


    Hi,

    I am trying to drop users from a specific database and getting the error below . Please help.

    TITLE: Microsoft SQL Server Management Studio

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

    Drop failed for User 'User1'. (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.5058.0+((SQL11_PCU_Main).140514-1820+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+User&LinkId=20476

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

    ADDITIONAL INFORMATION:

    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)

    The answer is in the error message:

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

    The user you are trying to drop owns a schema in the database. You need to reassign the ownership of this schema to a different user before you can drop the user.

  • SELECT s.name

    FROM sys.schemas s

    WHERE s.principal_id = USER_ID(‘TestUser’)

    ALTER AUTHORIZATION ON SCHEMA::SchemaName TO dbo

    GO

    DROP USER TestUser

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

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