Friday, March 9, 2012

How to drop a user defined database role in 2005?

Using Studio, I created a user defined database role but I can not delete it because

"TITLE: Microsoft SQL Server Management Studio

Drop failed for DatabaseRole 'test1'. (Microsoft.SqlServer.Smo)

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)

I am quite annoyed because the "owned schema" is db_owner, which can not be unselected. Quite an innovation. How do I drop this relationship?

i think the DB_Owner schema is owned by this role

run this statement to see the schema and owner ... check whether this role is the owner of any schema

SELECT s.name SchemaName, d.name SchemaOwnerName FROM sys.schemas s INNER JOIN sys.database_principals d ON s.principal_id= d.principal_id

if this role owner of DB_Owner Schema run the below statment to transfer the owner ship..

ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [db_owner]

Drop role test1

Madhu

|||Nice and simple. Does the trick. Thanks Madhu.

Cheers,

Sameer.

No comments:

Post a Comment