SQL Server 2008 - Search Query

I am not an expert on SQL. I am trying to elegantly solve the query problem that others should have had. Surprisingly, Google does not return anything that helps. Basically, my application has a search box. This search field allows the user to search for customers in the system. I have a table called "Client" in my SQL Server 2008 database. This table is defined as follows:

Customer

  • UserName (nvarchar)

  • FirstName (nvarchar)

  • LastName (nvarchar)

As you can imagine, my users will enter inquiries in different cases and, possibly, it is incorrect to name client names regularly. How can I fulfill a query to my customer table and return 25 results closest to their query? I do not know how to do this, and consider the three fields listed in my table.

Thank!

+3
source share
3 answers

. "" CONTAINSTABLE. , , , Lucene.

+4

, SOUNDEX .

SELECT TOP 25 UserName, FirstName, LastName
FROM Customer
WHERE DIFFERENCE( UserName, @SearchValue ) > 2
ORDER BY DIFFERENCE( UserName, @SearchValue ), UserName
+2

, ,

, , sql-.

0

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


All Articles