Solved

Using Contains with wildcards in SQL query

Posted on 2014-07-22
2
138 Views
Last Modified: 2014-07-22
I know how to use contains to produce results if for example I type CONTAINS(<fieldname>,'Administration AND Reception'), but how can I get results if I want to match partial words -

I have tried CONTAINS('Admin% AND Recept%') which doesn't work.
 
I Have also tried <fieldname> LIKE 'Admin%' AND<fieldname> LIKE 'Recept%', but that doesn't work either.

I need to find documents which contain both words.
0
Comment
Question by:jdthedj
2 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 40213259
You can either use:
 CONTAINS(<fieldname>, '"Admin*" AND "Recept*"') 

Open in new window

or
<fieldname> LIKE '% Admin%' AND<fieldname> LIKE '% Recept%'

Open in new window

The latter will not be using FULL TEXT SEARCH and would be slower in my opinion
0
 
LVL 3

Author Closing Comment

by:jdthedj
ID: 40213269
Thanks chaau - I didn't realise that I needed * and double quotes in CONTAINS instead of %
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now