MSSQL : replace by NULL

Dears,

  SELECT replace('hello','e',NULL) -- returns NULL
  SELECT replace('hello','5',NULL) -- returns also NULL (Here I'd expect it does nothing ; since there is no '5' in 'hello')

The documentation clearly states:

Returns NULL if any one of the arguments is NULL.

So the behavior is explained.

Is there a workaround, meaning if a pattern is found in a string ; like ‘e’ in hello ; a NULL value is emitted?

© 2025 Street Of Styles