UFN_SPONSORSHIP_ONEMOSTRECENTFORCOMMITMENT

Verifies that one and only one sponsorship is marked as the most recent for a given commitment.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@SPONSORSHIPCOMMITMENTID uniqueidentifier IN

Definition

Copy


create function dbo.UFN_SPONSORSHIP_ONEMOSTRECENTFORCOMMITMENT(
    @SPONSORSHIPCOMMITMENTID uniqueidentifier
)
returns bit
with execute as caller
as begin
    declare @COUNT smallint;

    select @COUNT = count(*)
    from dbo.SPONSORSHIP
    where SPONSORSHIPCOMMITMENTID = @SPONSORSHIPCOMMITMENTID
    and ISMOSTRECENTFORCOMMITMENT = 1;

    if @COUNT <= 1
        return 1;

    return 0;
end