• also you want to be using the sys.database_principals catalog view and not sysusers. This should be better

    declare @sql nvarchar(max)

    set @sql = ''

    SELECT @sql = @sql+

    '

    print ''Dropping '+name+'''

    execute master.dbo.sp_revokedbaccess '''+name+'''

    '

    FROM

    sys.database_principals

    WHERE

    name NOT IN('dbo','guest','INFORMATION_SCHEMA','sys','public')

    AND TYPE <> 'R'

    order by

    name

    execute (@sql)

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉