Function '%1!s!' is not allowed in the %2!s! clause when the FROM clause contains a nested INSERT, UPDATE, DELETE, or MERGE ...

Function '%1!s!' is not allowed in the %2!s! clause when the FROM clause contains a nested INSERT, UPDATE, DELETE, or MERGE statement. This is because the function performs user or system data access, or is assumed to perform this access. By default, a function is assumed to perform data access if it is not schema-bound.