hi
hope this helps
https://social.technet.microsoft.com/Forums/en-US/2ae014d2-9c52-4a51-9db7-f83885828142/how-to-use-cte-in-update-statement?forum=transactsql