UFN_PROSPECTPLANMANAGERHISTORY_VALIDPRIMARYMANAGERENDDATE

Validates that the end date of the historical prospect plan primary manager is after the start and end date of the current prospect plan primary manager.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@PROSPECTPLANID uniqueidentifier IN
@DATETO datetime IN

Definition

Copy


            CREATE function dbo.UFN_PROSPECTPLANMANAGERHISTORY_VALIDPRIMARYMANAGERENDDATE
            (
                @PROSPECTPLANID uniqueidentifier,
                @DATETO datetime
            )
            returns bit
            with execute as caller
            as begin

                if exists (
                    select top 1
                        ID
                    from
                        dbo.PROSPECTPLAN
                    where
                        ID = @PROSPECTPLANID and
                        (
                            (
                                (PRIMARYMANAGERSTARTDATE is not null) and
                                (PRIMARYMANAGERSTARTDATE < @DATETO)
                            ) or
                            (
                                (PRIMARYMANAGERENDDATE is not null) and
                                (PRIMARYMANAGERENDDATE < @DATETO)
                            )
                        )
                    )
                    return 0;

                return 1;

            end