Bug on Find Invalid Objects

DanAvniDanAvni Posts: 72 Bronze 2
edited August 22, 2014 8:44AM in SQL Prompt
I have the function below on a DB. the table ObjectPermissions does not exist anymore but the function does not list as an invalid object

ALTER FUNCTION [dbo].[CheckEnforceGroupPermissionsForEmployeeGUID]
(
@EmployeeGUID uniqueidentifier,
@EnforceGroupPermissionsForUserGuid uniqueidentifier
)
RETURNS bit
AS BEGIN
DECLARE @RetVal as bit
IF @EnforceGroupPermissionsForUserGuid is null
BEGIN
SET @RetVal = 1
end
ELSE
begin --running against a specific user
declare @GroupGUID uniqueidentifier
select @GroupGUID = GroupGuid
From Employees
Where Employees.Guid = @EmployeeGUID
if @GroupGUID is null
begin --no group for employee
SET @RetVal = 0
end
else
begin --employee has a group
if exists ( Select *
From ObjectPermissions
where ObjectGuid = @GroupGUID AND
UserGuid = @EnforceGroupPermissionsForUserGuid AND
ObjectType = 0 )
begin
SET @RetVal = 1
end
else
begin
SET @RetVal = 0
end
end
end
RETURN @RetVal

END
Dan Avni

Comments

Sign In or Register to comment.