T-SQL 101: 50 Using CHARINDEX and PATINDEX to find one string in another in SQL Server
It’s useful to be able to find one string within another string. T-SQL has two basic functions for that: CHARINDEX and PATINDEX.
CHARINDEX is used to see if one string appears within another string. Take a look at this code:


In this first example, I asked SQL Server to look for the string lot in the string Hellothere. You can see that it found it at position 4.
2019-12-30



