USP_ROLESYNC_SYSTEMROLE_PURGEAPPUSERS
Deletes APPUSER records that belong to no System Roles and are not System Administrators.
Definition
Copy
create procedure dbo.USP_ROLESYNC_SYSTEMROLE_PURGEAPPUSERS
as
--Used by the RoleSync utility to remove APPUSERS that are
--not assigned to any SYSTEMROLE and are not SYSADMINS
set nocount on;
BEGIN TRY
delete from dbo.APPUSER
where APPUSER.ISSYSADMIN = 0
and not exists (
select APPUSERID from dbo.SYSTEMROLEAPPUSER
where SYSTEMROLEAPPUSER.APPUSERID = APPUSER.ID
);
return 0;
END TRY
BEGIN CATCH
exec dbo.USP_RAISE_ERROR;
return 1;
END CATCH