Using contains () in sql server

I have a table name Product contains 3 columns as:

 Product-id name Price 

The name column contains all product names.

Example: 1340 GPS, 1340T GPS, etc.

When I write

 select top 10 * from product where contains(name,'1340'); 

Result 1 line 1340 GPS

but when searching

 select top 10 * from product where name like '%1340%'; 

Then the result is 1340 GPS and 1340T GPS .

Actually, my requirement is to use contains() , but it should show both lines, such as LIKE .

How to do it:?

Please, help

Thanks in advance

+7
source share
2 answers

Here is a direct way to do this. you can use "*" before it contains the same syntax as the operator. but you need to use a double quote before and after the search string. check the following query:

 SELECT * FROM product WHERE CONTAINS(name,'"*1340*"'); 

it will definitely work.

+10
source

select * from the product where FREETEXT (product., '"1340"')

+1
source

All Articles