.NET sql selection

Posted on 2010-01-07
Last Modified: 2013-11-07
I am building a Select statement.  If a criteria is present I need to add an AND to my WHERE clause to pull records where a field contains a particular word.

SELECT * from Import_Tables
WHERE project=2
AND instr(FieldToSearch,"look")>0

but instr (instring) is not a recognized built-in function.

What syntax can I use?
Question by:kkbenj
    LVL 75

    Accepted Solution

    different opions

    SELECT * from Import_Tables
    WHERE project=2
    AND FieldToSearch like '%look%'

    SELECT * from Import_Tables
    WHERE project=2
    AND CHARINDEX('look', FieldToSearch) > 0

    Author Closing Comment

    CharIndex was exactly what I was looking for.

    Thanks for your speedy response!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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