11 November 2008
Drop and recreate database Logins
Script below loop database users then drop and recreate them one by one:
DECLARE @UserName Varchar(500)
DECLARE UsersCurr Cursor For Select Name FROM sysusers WHERE (islogin = 1) AND (name <> 'dbo') AND (name <> 'guest')
Open UsersCurr
Fetch Next From UsersCurr Into @UserName
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sp_revokedbaccess @UserName
EXEC sp_droplogin @UserName
EXEC sp_addlogin @UserName, '123'
EXEC sp_grantdbaccess @UserName, @UserName
EXEC sp_addrolemember 'DYNGRP', @UserName
Fetch Next From UsersCurr Into @UserName
END
Close UsersCurr
DEALLOCATE UsersCurr
You can modify the above script to fit your needs.
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using
Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.