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.
Regards,
--
Mohammad R. Daoud
MCP, MCBMSP, MCTS, MCBMSS
Software Development Manager
+962 - 79 - 999 65 85
Dynamics Innovations
daoudm@dynamicsinnovations.com
http://www.dynamicsinnovations.com/
No comments:
Post a Comment