Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the full-word matching and implementation code of SqlServer English words

Shulou Source: shulou.com Published: 2022-05-31 12:54:27 10月26日 Update

This article introduces the full-word matching of SqlServer English words and the implementation code, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

Full word matching of SqlServer English words

Environment: Vs2013+Sql Server2012

Problem: now the database records are as follows:

The Sentence column holds English sentences, and now I want to find all the sentences that contain "I" (word). If I use "Sentence like" as a condition, then, like the one selected above with the word "it" (case-insensitive), it will also be Select, and I just want to find the record of the sentence that contains the word "I".

Solution: SqlServer provides pattern matching, similar to regular, refer to the relevant documentation for details.

I first wrote a condition like this:

Sentence like'% [^ a-zA-Z] I [^ a-zA-Z]%'

It is found that the first item in the above picture, that is, "I would...", the word that begins with "I" has not been Select, that is to say, this condition matches a non-alphabetic symbol in front of it (no character is not allowed). By the same token, a non-alphabetic symbol is required at the end (it is not allowed without characters), 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'

However, it feels troublesome to add a non-letter number before and after the Sentence, like the original "I would like I", and change it into "I would like I" (with a space before and after each), so that you can match the condition that was written at the beginning:

'' + Sentence+' 'like'% [^ a-zA-Z] I [^ a-zA-Z]%'

About SqlServer English word full-word matching and how the implementation code is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Word English condition whole word content sentence letter code picture above that is character more symbol help yes that is to say interest original size boy. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker Linux NVidia Shulou Tech Info