Hi @RogerSchlueter-7899 ,
Welcome to Microsoft Q&A!
The multi-part identifier "cteTotal.TransactionTotal" could not be bound.
You could consider cteTotal as a temporary table and you also need to include the cteTotal in the update statement, otherwise the sql server could not recognize where TransactionTotal is from.
Please also refer below:
WITH cteTotal(TransactionTotal) AS
(
SELECT
SUM(Amount) as TransactionTotal
FROM
#NewDetails
)
UPDATE
FinancialAccounts
SET
Balance = Balance + (select TransactionTotal from cteTotal)
WHERE
AccountID = @AccountID;
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.