UFN_ADHOCQUERYFOLDER_GETCLOSESTANCESTORDEFAULTINGPERMISSIONS

Returns the closest ancestor to a folder that defaults permissions.

Return

Return Type
uniqueidentifier

Parameters

Parameter Parameter Type Mode Description
@FOLDERID uniqueidentifier IN

Definition

Copy


            create function dbo.UFN_ADHOCQUERYFOLDER_GETCLOSESTANCESTORDEFAULTINGPERMISSIONS
            (
                @FOLDERID uniqueidentifier
            )
            returns uniqueidentifier
            with execute as caller
            as
            begin
                declare @ANCESTOR uniqueidentifier

                select top 1
                    @ANCESTOR = ID
                from dbo.UFN_ADHOCQUERY_GETANCESTORS(@FOLDERID)
                where
                    APPLYASDEFAULTPERMISSIONSFORALLSUBFOLDERS = 1 and
                    LEVEL > 0
                order by LEVEL

                return @ANCESTOR
            end