.NET sql selection

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?
kkbenjAsked:
Who is Participating?
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
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
0
 
kkbenjAuthor Commented:
CharIndex was exactly what I was looking for.

Thanks for your speedy response!
0
All Courses

From novice to tech pro — start learning today.