Update statement with a function
Answering my own question, I found this link, which contains the answer:


  ...by having this as a function on your update, you are essentially
  calling the function as many number of times as there are rows in the
  table. This is not the best way to do this, and is known as row-by-row
  processing, rather than set-based.
  
  Try and take the processing that the function is doing and apply it to
  the table in one go rather than this one-at-a-time approach.