Error trying to delete database user account schema

I am trying to remove a user schema from a database and I am getting the following error:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Drop failed for Schema 'ext_owner'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.4035.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+Schema&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

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

Cannot drop schema 'ext_owner' because it is being referenced by object 'getroles'. (Microsoft SQL Server, Error: 3729)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4035&EvtSrc=MSSQLServer&EvtID=3729&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

What is a getroles object?

How do I get rid of a link to delete an old account?

+5
source share
3 answers
SELECT * FROM sys.objects 
WHERE name = 'getroles' 
AND schema_id = SCHEMA_ID('ext_owner');

Then do:

DROP <object type> ext_owner.getroles;

- or

ALTER SCHEMA <some other schema> TRANSFER ext_owner.getroles;

You may have to repeat this several times. You cannot refuse a scheme that is not empty.

+7
source

You can query the system tablesys.objects to try to find additional information about what getroles might be.

Try

SELECT * FROM sys.objects WHERE name LIKE '%getroles%'

, . , , .

+2

Try using:

SELECT * FROM sys.objects WHERE name = 'getroles'

I assume this is a function or stored procedure that this user created in his own schema (possibly by accident). Throw it (if not in use) and you should be good to go.

+2
source

All Articles