• Interesting stuff.

    Performance-wise, how does fn_reverse_charIndex hold up against (LEN(@expr) - CHARINDEX(@char, REVERSE(@expr)) + 1)

    And, seeing as your fn_simplemath function appears only to handle one expression at a time, how would it (injection aside) hold up against:

    CREATE TABLE #result (res NUMERIC);

    INSERT INTO #result (res) EXEC ('SELECT ' + @expr)

    SELECT res FROM #result

    DROP TABLE #result

    J.