By 14 Marzo 2012 0 Comments

The database principal owns a schema in the database, and cannot be dropped.

E’ possibile, in fase di cancellazione di un utente, imbattersi in questo errore:

Drop failed for User ‘xxxxxx’. (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)

questo succede perchè l’utente è ancora MEMBRO di qualche Schema (nel database) e per cancellarlo bisogna prima rimuoverlo da questi schemi.
Utilizzare come SQL nel DB :

SELECT sc.name
FROM sys.schemas sc
WHERE sc.principal_id = USER_ID(‘xxxxx’)

per vedere in che schemi è l’utente. Dopodichè assegnare a DBO questi schemi in modo da “estrometterlo”

ALTER AUTHORIZATION
ON SCHEMA::db_owner
TO dbo

Posted in: Sql Server

About the Author:

shared on wplocker.com