PATINDEX searches for a pattern of characters within a string. : PATINDEX « String Functions « SQL Server / T-SQL Tutorial






PATINDEX is not case sensitive.
PATINDEX returns 0 if no match is found.
PATINDEX allows the handling of wildcards, unlike CHARINDEX.

12> SELECT PATINDEX("%java2s%","This is www.java2s.com")
13>
14> GO
-----------
         13

(1 rows affected)








12.11.PATINDEX
12.11.1.PATINDEX searches for a pattern of characters within a string.
12.11.2.SELECT PATINDEX('%M_rs%', 'The stars near Mars are far from ours')
12.11.3.select PATINDEX('%v_r%', 'SQL Server')
12.11.4.WHERE PATINDEX('%computer[^s]%', notes) > 0
12.11.5.Finding the Start Position of a String Within Another String Using Wildcards