UFN_MEMBER_VALIDNUMBEROFMEMBERS

Validates the number of members in a membership as allowed in the membership level.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@MEMBERSHIPID uniqueidentifier IN

Definition

Copy


        CREATE function dbo.UFN_MEMBER_VALIDNUMBEROFMEMBERS
        (
            @MEMBERSHIPID uniqueidentifier
        )
        returns bit
        with execute as caller
        as begin

            declare @MEMBERSALLOWED smallint
            set @MEMBERSALLOWED = dbo.UFN_MEMBER_NUMBEROFMEMBERSALLOWED(@MEMBERSHIPID)

            declare @MEMBERCOUNT smallint

            select @MEMBERCOUNT = count(ID)
            from dbo.MEMBER
            where MEMBERSHIPID = @MEMBERSHIPID 
                and ISDROPPED = 0

            if @MEMBERCOUNT > @MEMBERSALLOWED
                return 0;

            return 1;
        end