This topic contains and tries to cover following subjects
- Explanation of PATINDEX() function in SQL
- Syntax of PATINDEX() function in SQL
- Example to PATINDEX() function in SQL
Articles contains and tries to provide answer to following questions and issues:
- What is PATINDEX() function..
- How to use PATINDEX() function..
- How to find a string an occurrence of pattern with using wildchar ds
Articles may require following knowledge:
- Basic query flow in SQL
- SQL Server Management Studio
- SQL Server string functions
Explanation of PATINDEX() function in SQL
PATINDEX function is used to find an occurrence of a string with specifying it between wildchar ds. Lets assume that we have a column of a table which contains string s, and we want to find where "S" or "Q" letters start - start position of provided char acters or sequence within the wildchar ds - any of them. Similar to check with OR. In such cases, we can use PATINDEX function.
If the provided source string is not encountered in target string , the function returns zero value which indicates "it is not found".
Syntax of PATINDEX() function in SQL
Syntax for stuff function is as follows:
PATINDEX( pattern , expression )
Example of PATINDEX() function in SQL
To demonstrate how to find a start position of a string in another string using wildchar d and pattern in a table of a column, we will use a SELECT query. Lets provide a string , and look for a pattern within it.
Query is as follows: