Solved

Using Contains with wildcards in SQL query

Posted on 2014-07-22
2
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

632 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