Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report