Revision: 33287
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 7, 2010 18:59 by johnny2shoes
Initial Code
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
Initial URL
Initial Description
Initial Title
Dropping a Role from a database
Initial Tags
Initial Language
SQL