How to Detect Similar Strings Where one may contain a spelling error RRS feed

  • Question

  • User-1193791088 posted

    I wish to be able to detect if someone is entering data into a field that may be the same but one may contain a spelling error or be off by one word.

    My table is a list of tasks

    A task in the database may be "Clean Bathroom"

    If an admin wants to enter a new task for selection and enters "Clean Bath Room" or "Clean Bath-Room" or they enter "Clean Baathroom"

    This is for a Stored Procedure

    Thursday, August 23, 2018 4:48 AM

All replies

  • User347430248 posted

    Hi RobertH3,

    You can try to use Soundex() or Difference() to get the desired result.

    You can refer example below.

    Data in table.


    SELECT *
    FROM comp_test
    WHERE SOUNDEX('Clean Bathroom') = SOUNDEX(col1)
    SELECT *
    FROM comp_test
    WHERE DIFFERENCE(col1, 'Clean Bathroom') >= 3



    SOUNDEX (Transact-SQL)

    DIFFERENCE (Transact-SQL)



    Monday, August 27, 2018 3:03 AM