Environment: Vs2013+sql Server2012
Problem: The database is now logged as follows:
Sentence column is the English sentence, I want to find out all the sentences containing "I" (words), if I use sentence like '%I ', as a condition, then as the selected one has a word "it" (case-insensitive), it will also be select out, And I just want to find a record of the sentence that contains the word "I".
WORKAROUND: SQL Server provides a pattern match, similar to regular, for a detailed review of the relevant documentation.
I first wrote a condition like this:
Sentence like '%[^a-za-z]i[^a-za-z]% '
The first in the discovery, that is, "I would ...", the word "I" is not selected out, that is, this condition matches the front to a non-letter symbol (no character is not possible), then the same reason, The last side also needs a non-letter symbol (no characters are also not possible), so it can be changed to:
Sentence like '%[^a-za-z]i[^a-za-z]% ' or sentence like ' i[^a-za-z]% ' or sentence like '%[^a-za-z]i '
But it feels more troublesome, if the sentence before and after adding a non-letter number, such as the original "I would like I", it becomes "I would likes I" (before and after each plus a space), so that it can match the first write the condition:
' +sentence+ ' like '%[^a-za-z]i[^a-za-z]% '
SQL Server English word full word match