A late thought...
The function idea has one "hole" - if an empty or null varchar is passed.
imho, use:
RETURN(SELECT ISNULL((DATALENGTH(@String) - DATALENGTH(REPLACE(@String, @Search, '')))
/ NULLIF(DATALENGTH(@Search), 0), 0))
I've been "bit" by that before.