Patindex TSQL Tutorial

The Patindex funcion returns the starting position of the first occurrence of a pattern in a specified expression or return zero if the pattern is not found.

Patindex function syntax

patindex ( '%pattern%' , expression )

Patindex Example :

idfirst_namecountry
1TomUS
2MichaelUS
3SophiaFrance
4EmmaGermany
5OliviaUS
6DavidEngland

USE model;
GO
SELECT PATINDEX('%u%',country) as 'Example'
FROM dbo.students;
GO

Result:

Example
1
1
0
0
1
0

See also: T-SQL Functions -> Substring | Replace | Right | Rtrim | Upper