UFN_BBNC_GETMATCHINGBUSINESSID

Returns the ID of a specified constituent's business organization for Blackbaud Internet Solutions.

Return

Return Type
uniqueidentifier

Parameters

Parameter Parameter Type Mode Description
@MAPID int IN
@ORGANIZATIONNAME nvarchar(100) IN

Definition

Copy


            CREATE function dbo.UFN_BBNC_GETMATCHINGBUSINESSID
            (
                @MAPID int,
                @ORGANIZATIONNAME nvarchar(100)
            )
            returns uniqueidentifier
            as
            begin
                return
                (
                    select top (1)
                        [BUSINESS].[ID]
                    from
                        dbo.CONSTITUENT
                        left join dbo.RELATIONSHIP on CONSTITUENT.ID = RELATIONSHIP.RELATIONSHIPCONSTITUENTID
                        left join dbo.CONSTITUENT as BUSINESS on RELATIONSHIP.RECIPROCALCONSTITUENTID = BUSINESS.ID
                    where
                        [CONSTITUENT].[SEQUENCEID] = @MAPID
                        and upper([BUSINESS].[KEYNAME]) = upper(@ORGANIZATIONNAME)
                    order by
                        [RELATIONSHIP].[DATECHANGED] desc
                )
            end