CHARINDEX
Description
Sample Source Pattern
Syntax
CHARINDEX( expression_to_find, expression_to_search [, start] )CHARINDEX( <expr1>, <expr2> [ , <start_pos> ] )String.indexOf( search_value [, index] )Examples
SELECT CHARINDEX('t', 'Customer') AS MatchPosition; INDEX|
-----------+
33|SELECT CHARINDEX('t', 'Customer') AS MatchPosition; INDEX|
-----------+
33|CREATE OR REPLACE FUNCTION get_index
(
expression_to_find varchar,
expression_to_search varchar,
start_index float
)
RETURNS float
LANGUAGE JAVASCRIPT
AS
$$
return EXPRESSION_TO_SEARCH.indexOf(EXPRESSION_TO_FIND, START_INDEX)+1;
$$;
SELECT GET_INDEX('and', 'Give your heart and soul to me, and life will always be la vie en rose', 20) AS INDEX; INDEX|
-----------+
33|Last updated
Was this helpful?