Nice but can't help but feel it's overcomplicating it a bit. What about:
DECLARE @ReturnValue AS INT
SET @ReturnValue = 0
IF LEN(@SearchString) > 0
BEGIN
SET @ReturnValue = (LEN(@InputString) - LEN(REPLACE(@InputString,@SearchString,''))) / LEN(@SearchString)
END
RETURN @ReturnValue