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


Delete All Database User Accounts for a Given Server Login


Delete All Database User Accounts for a Given Server Login

Author
Message
hakim.ali
hakim.ali
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1329 Visits: 1090
Comments posted to this topic are about the item Delete All Database User Accounts for a Given Server Login

Hakim Ali
www.sqlzen.com
Prat!K
Prat!K
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 26
This is good topic but I want to delete 2 users forcefully from 253 databases then how can i do it?
hakim.ali
hakim.ali
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1329 Visits: 1090
Prat!K (4/14/2014)
This is good topic but I want to delete 2 users forcefully from 253 databases then how can i do it?


Towards the top of my script there is this line:

set @LoginName = 'LOGIN_NAME_HERE'

Set the server level login name associated with one of your users here, and run the script. Then set @LoginName to the login name of your other user, and run the script again. This will accomplish what you want. I'm assuming these two users and the 253 databases are on the same server. If they are on more than one server, just repeat the process on each server.

Hakim Ali
www.sqlzen.com
Iwas Bornready
Iwas Bornready
SSC-Insane
SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)

Group: General Forum Members
Points: 22612 Visits: 885
Great script, thanks.
SQL-DBA-01
SQL-DBA-01
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8455 Visits: 3581
Nice Script. If anyone do not want to drop the user just change that to "Select" so that you can check what are the results before droping the user.




select @sql = 'use [' + DB + ']; select user [' + UserName + ']'



Thanks.
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