Showing posts with label Microsoft SQL Server Administration. Show all posts
Showing posts with label Microsoft SQL Server Administration. Show all posts

Wednesday, 19 February 2014

The database principal owns a database role and cannot be dropped.

SQL Command:
DROP USER [User_NAME]

Error Message:
The database principal owns a database role and cannot be dropped.

Solution:
SELECT T2.Name, T1.Name
FROM sys.database_principals AS T1 JOIN sys.database_principals AS T2 ON T1.owning_principal_id = T2.principal_id
 WHERE T1.type = 'R' AND T2.name = 'USER_NAME'

Output:
Database roles from which to remove this user before re-trying the deletion.

Thursday, 3 October 2013

Understanding Microsoft SQL Server permissions

Below is a very good article about the permissions check order. Also explains chaining; when an object accesses another object.

http://technet.microsoft.com/en-us/library/dd283095(v=sql.100).aspx
Although the article was for SQL Server 2008, most concepts are still valid for 2012 version.

MS SQL Server: Changing database diagram ownership

- Current user to be removed from the DB to be able to transfer object ownership!!
- Ownership can now be transferred to members of the db_owbner role.


For me, I just cannot get the rational behind this restriction!


For actually changing the object ownership:
http://support.microsoft.com/kb/275312/en-gb