UFN_BANK_GETENDINGBALANCE

This function returns the aggregated current balance for all accounts associated with a bank.

Return

Return Type
decimal(19, 4)

Parameters

Parameter Parameter Type Mode Description
@BANKID uniqueidentifier IN

Definition

Copy


            CREATE function dbo.UFN_BANK_GETENDINGBALANCE
                (
                    @BANKID uniqueidentifier
                )
                returns decimal(19, 4)
                with execute as caller
                as begin
                    declare @BALANCE decimal(19, 4);

                    select
                        @BALANCE = coalesce(SUM(dbo.UFN_BANKACCOUNT_GETENDINGBALANCE(ID)), 0)
                    from
                        dbo.BANKACCOUNT
                    where
                        BANKACCOUNT.BANKID = @BANKID

                    return @BALANCE
                end