Search strings with special characters RRS feed

  • Question

  • I do have an entry in my database which is ABC-28 and sometimes ABCD/45, how do i find them if the user just type in just only the alphanumeric characters like ABC28 or ABCD45. The special characters like '-' and '/' are sometimes in the middle of the string or in the end. 


    • Edited by Dikong42 Thursday, June 7, 2018 1:25 PM
    Thursday, June 7, 2018 1:24 PM


  • Hi Dikong42,

    One possible way could be that you replace the special characters from your column values before comparing against the user input string. Something like below:

    SELECT * FROM TableName
    WHERE REPLACE(REPLACE(StringColumnName,'-',''),'/','') = 'UserInputString'
    Please note that if the special character is making the value unique then you will have multiple rows returned, however I assume your column's selectivity is not dependent on these special characters.

    Please mark it as Answered if it answered your question or mark it as Helpful if it helped you solve your problem.

    Thursday, June 7, 2018 3:15 PM