SQL Server English word full word match

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.