PATINDEX function [String]
Function
Syntax
Parameters
Examples
Usage
Standards and
compatibility
See also
PI function [Numeric]
Function
Syntax
Examples
Returns an integer representing the starting position of the first occurrence of
a pattern in a string.
PATINDEX ( '% pattern %', string_expression )
pattern
The pattern to be searched for. If the leading percent wild card is
omitted, PATINDEX returns one (1) if the pattern occurs at the beginning of
the string, and zero if not.
The pattern uses the same wild cards as the LIKE comparison. These are as
follows:
Wild card
Matches
_ (underscore)
Any one character
% (percent)
Any string of zero or more characters
[]
Any single character in the specified range or set
[^]
Any single character not in the specified range or set
string-expression
The string to be searched for the pattern.
The following statement returns the value 2.
SELECT PATINDEX( '%hoco%', 'chocolate' )
The following statement returns the value 11.
SELECT PATINDEX ('%4_5_', '0a1A 2a3A 4a5A')
PATINDEX returns the starting position of the first occurrence of the
pattern. If the pattern is not found, it returns zero (0).
♦
SQL/92
Vendor extension.
♦
Compatible with Adaptive Server Enterprise, except that the
Sybase
USING clause is not supported.
"LIKE conditions" on page 241
"LOCATE function" on page 345
Returns the numeric value PI.
PI ( * )
The following statement returns the value 3.141592653....
Chapter 8 SQL Functions
355
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers