Last post Aug 27, 2018 03:03 AM by Deepak Panchal
Member
8 Points
100 Posts
Aug 23, 2018 04:48 AM|RobertH3|LINK
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
Contributor
2990 Points
1210 Posts
Aug 27, 2018 03:03 AM|Deepak Panchal|LINK
Hi RobertH3,
You can try to use Soundex() or Difference() to get the desired result.
You can refer example below.
Data in table.
Query:
SELECT * FROM comp_test WHERE SOUNDEX('Clean Bathroom') = SOUNDEX(col1) OR SELECT * FROM comp_test WHERE DIFFERENCE(col1, 'Clean Bathroom') >= 3
Output:
Reference:
SOUNDEX (Transact-SQL)
DIFFERENCE (Transact-SQL)
Regards
Deepak
Member
8 Points
100 Posts
How to Detect Similar Strings Where one may contain a spelling error
Aug 23, 2018 04:48 AM|RobertH3|LINK
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
Contributor
2990 Points
1210 Posts
Re: How to Detect Similar Strings Where one may contain a spelling error
Aug 27, 2018 03:03 AM|Deepak Panchal|LINK
Hi RobertH3,
You can try to use Soundex() or Difference() to get the desired result.
You can refer example below.
Data in table.
Query:
Output:
Reference:
SOUNDEX (Transact-SQL)
DIFFERENCE (Transact-SQL)
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.