SQL Contains Sentence problem

Posted on 2011-10-09
Last Modified: 2012-05-12
when using this where sentence:

where contains (TYPE, '"HEP C"')

I get in my results HEP C  and HEP B.  how can I rewrite this contains sentence to only get fields with HEP C . this problem only appears when I use a single character at the end.
Question by:lespbaj
    LVL 7

    Expert Comment

    i would use:
    WHERE columnname LIKE '%HEP C%'
    LVL 26

    Expert Comment

    SELECT ....
    FROM ....
    WHERE type LIKE '%HEP C%'
    LVL 18

    Accepted Solution

    Using Contains is for Full Text searching. Make sure your individual C and B characters are indexed as if they are words (and any other individual character-words) and are not in the stop list.

    See, for example.

    You could use full-text search to get a list of all matching rows for the word "hep" and from that, do a Like search for "%Hep c%" which would be faster than just using Like on the whole table (depending on its size).

    Gary Davis

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    779 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

    9 Experts available now in Live!

    Get 1:1 Help Now