SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to drop a user attached to same schema with out dropping schema


How to drop a user attached to same schema with out dropping schema

Author
Message
virgo
virgo
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1048 Visits: 520
As saw under schema properties below

A database user can be dropped without dropping objects in a corresponding schema.


My question here is when I am trying to drop a user ex 'testuser' which is tagged to a schema 'testuser' which has few objects (table and function) under that schema.

When I am trying to drop the user am getting a below error msg.


Msg 3729, Level 16, State 1, Procedure sp_revokedbaccess, Line 51
Cannot drop schema 'testuser' because it is being referenced by object 'table'


So i want to know the best method to drop the existing user 'testuser' and recreate it with different set of permissions.


Thanks in advance!!
Mike01
Mike01
SSCrazy Eights
SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)

Group: General Forum Members
Points: 9984 Visits: 2567
The user is also the owner of the schema. Change the owner of the schema, then you can drop the user.

 ALTER AUTHORIZATION ON SCHEMA::[Testuser] TO [dbo]
GO



For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
virgo
virgo
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1048 Visits: 520
Thanks Mike for the reply...but one strange thing here in my scenario i canot change the schema to dbo coz the same objects exists on dbo schema as well as testuser.

So will it be better
1) to drop the schema then drop the user
2) create the schema again and assign it new user created.

or is there any other best way to do with out droping the schema?

Cheers!!
Oliiii
Oliiii
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5056 Visits: 777
It doesn't change the schema to dbo, it changes the owner of the schema to dbo, you'll still have both your schemas and your user will be free to be droped.

You can reasign the schema to your user after you've changed the rights.
You can also change the rights without droping the user though.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search