/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
USE [DATABASE name] GO DECLARE @RoleName sysname SET @RoleName = N'role name' BEGIN DECLARE @RoleMemberName sysname DECLARE Member_Cursor CURSOR FOR SELECT [name] FROM dbo . sysusers WHERE uid IN ( SELECT memberuid FROM dbo . sysmembers WHERE groupuid IN ( SELECT uid FROM dbo . sysusers WHERE [name] = @RoleName AND issqlrole = 1 )) OPEN Member_Cursor ; FETCH NEXT FROM Member_Cursor INTO @RoleMemberName WHILE @@FETCH_STATUS = 0 BEGIN EXEC sp_droprolemember @rolename = @RoleName , @membername = @RoleMemberName FETCH NEXT FROM Member_Cursor INTO @RoleMemberName END ; CLOSE Member_Cursor ; DEALLOCATE Member_Cursor ; END GO DROP ROLE [rolename] GO