• Just looks like Ram called the function by an earlier name.

    I made a slight modification, converting the string types that will be stripped out to a parameter rather than inputting the expression. I also added more characters to the test string just to be sure it was capturing a few more non-alphanumeric characters for my own peace of mind.

    CREATE FUNCTION dbo.GEN_FN_StripCharacters

    (

    @strMatchType NVARCHAR(3),

    @strInputString NVARCHAR(MAX)

    )

    /*

    ---Created By : Ram

    --Date : 15-Feb-2013

    --- Purpose : To remove the specified Characters in the Given String

    Alphabetic only: SELECT dbo.fn_StripCharacters('a1!s2@d3#f4$', '^a-z')

    Numeric only: SELECT dbo.fn_StripCharacters('a1!s2@d3#f4$', '^0-9+-/')

    Alphanumeric only: SELECT dbo.fn_StripCharacters('a1!s2@d3#f4$', '^a-z0-9')

    Non-alphanumeric: SELECT dbo.fn_StripCharacters('a1!s2@d3#f4$', 'a-z0-9')

    --Modified by : Ed

    --Date : 01-Jul-2013

    Converted match strings into a match type parameter

    A-Alpha

    N-Numeric

    AN-AlphaNumeric

    Precede with ^ to denote NOT

    '^AN' = Not AlphaNumeric

    */

    RETURNS NVARCHAR(MAX)

    AS

    BEGIN

    DECLARE @strMatchExpression varchar(15)

    SET @strMatchExpression = '%[' + CASE @strMatchType

    WHEN 'A' THEN 'a-z'

    WHEN '^A' THEN '^a-z'

    WHEN 'N' THEN '0-9+-/'

    WHEN '^N' THEN '^0-9+-/'

    WHEN 'AN' THEN 'a-z0-9'

    WHEN '^AN' THEN '^a-z0-9'

    END + ']%';

    WHILE

    PATINDEX( @strMatchExpression , @strInputString ) > 0

    SET @strInputString = STUFF( @strInputString , PATINDEX( @strMatchExpression , @strInputString ) , 1 , '' );

    RETURN @strInputString;

    END;

    SELECT dbo.GEN_FN_StripCharacters('a','a"1!S2@{]d3#f4$`~''')

    SELECT dbo.GEN_FN_StripCharacters('^a','a"1!S2@{]d3#f4$`~''')

    SELECT dbo.GEN_FN_StripCharacters('n','a"1!S2@{]d3#f4$`~''')

    SELECT dbo.GEN_FN_StripCharacters('^n','a"1!S2@{]d3#f4$`~''')

    SELECT dbo.GEN_FN_StripCharacters('an','a"1!S2@{]d3#f4$`~''')

    SELECT dbo.GEN_FN_StripCharacters('^an','a"1!S2@{]d3#f4$`~''')