PATINDEX
string transform
What changes
- Input
- string arguments
- Output or change
- string or integer
- Return type
- bigint if expression is of the varchar(max) or nvarchar(max) data types; otherwise int.
Syntax at a glance
PATINDEX ( '%pattern%' , expression )
Work example
Locate text that matches a wildcard pattern inside a value.
Use LIKE wildcard rules, then validate the full value before accepting an import.
Check your work PATINDEX returns zero for no match and null when the searched expression is null.
Practice SQL
Open in SQL FlowSELECT PATINDEX('%[0-9]%', 'Batch7') AS first_digit_position;
Open Microsoft Learn for full syntax, permissions, and details for your version.