Loading lesson path
Concept visual
Start at both ends
Search for "t" in string "Customer", and return position:
CHARINDEX('t', 'Customer') AS MatchPosition;The CHARINDEX() function searches for a substring in a string, and returns the position. If the substring is not found, this function returns 0.
Formula
This function performs a case - insensitive search.substring, string, start )
Required. The substring to search for string Required. The string to be searched start Optional. The position where the search will start (if you do not want to start at the beginning of s tring ).
SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
Search for "OM" in string "Customer", and return position:
CHARINDEX('OM', 'Customer') AS MatchPosition;Search for "mer" in string "Customer", and return position (start in position
3):
SELECT CHARINDEX('mer', 'Customer', 3) AS MatchPosition;❮ SQL Server Functions