UFN_SITEID_MAPFROM_REVENUEID_2

Return

Return Type
table

Parameters

Parameter Parameter Type Mode Description
@REVENUEID uniqueidentifier IN

Definition

Copy


      -- This _2 version has been created for performance improvement and anew instead of modifying the existing one

      -- in favor of keeping it's initial impact limited to the reports which use it.

      -- If it keeps working as expected after deployment, the existing one can be replaced

      -- with this one.

            CREATE function dbo.UFN_SITEID_MAPFROM_REVENUEID_2
            (
                @REVENUEID uniqueidentifier
            )
            returns table
            as
            return
                select distinct SITES.SITEID
                from (
                select ID
                        from dbo.FINANCIALTRANSACTIONLINEITEM
                          where FINANCIALTRANSACTIONLINEITEM.FINANCIALTRANSACTIONID = @REVENUEID
                        and FINANCIALTRANSACTIONLINEITEM.DELETEDON is null
             ) FTLI
        cross apply dbo.UFN_SITEID_MAPFROM_REVENUESPLITID(FTLI.ID) SITES;