Partially matching name fields in SQL Server

I need to enable partial match when searching by name. He currently works with Like '%@name%' , but he's not good enough.

We need to enable input both by name and by name, and both should be partial, so I assume the full text is the way to go.

The problem is that I cannot get it to perform a partial name match. For example, a search for my name (Fedor Hajdu) will work if I type all the parts in full, but not in part (it should match the search for 'fe ha' , for example.

How can i achieve this? Is it possible to set up a full-text index to make something like a syllable match?

+6
source share
2 answers

humm three options to help you:

  • INFLECTIONAL form ( Link )
  • CONTAINS NEAR ( Link )
  • CONTAINS WITH WEIGHTED VALUES ( LINK )

If this does not help, get the string "fe ha" and add "%" to each empty space and run the Like command:

 Like '%fe%ha%' 
+3
source

Using CONTAINS () or CONTAINSTABLE (), all you have to do is add * to the end of the corresponding line:

CONTAINS (Description, '"top *"');

If you have a string as a parameter, you can concatenate as follows:

SET @SearchTerm = '"' + @NameParameter + '*"'

CONTAINS (Description, SearchTerm);

https://technet.microsoft.com/en-us/library/ms142492(v=sql.105).aspx

0
source

Source: https://habr.com/ru/post/912471/


All Articles