Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for a word in a string

Status
Not open for further replies.

kgomotso

Programmer
Oct 31, 2000
20
ZA
How do I search for a word in a string without using %like% because %like% only finds a string that begins with the word and not that actually has an occurance of the word(it could be in the middle of the string)
 
charindex(ColumnName,'what you search') John Fill
ivfmd@mail.md
 
CharIndex will actually return a number -- that number will be the starting position in the string for the text you are searching for. If you SELECT statement states "WHERE FieldName Like '%searchstring%' then you should get matches whether the searchstring is at the beginning, end, or anywhere inside the string. The only way you would only get matches that start with searchstring is if you left off the wildcard at the beginning (i.e. WHERE FieldName Like 'searchstring%').
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top