SELECTCHARINDEX('t', 'Customer') AS MatchPosition;
Result:
INDEX|
-----------+
33|
Code:
OUT -> SqlServer_01.sql
SELECTCHARINDEX('t', 'Customer') AS MatchPosition;
Result:
INDEX|
-----------+
33|
Indexes in Transact start at 1, instead of JavaScript which start at 0.
Code:
CREATE OR REPLACEFUNCTIONget_index( expression_to_find varchar, expression_to_search varchar, start_index float)RETURNSfloatLANGUAGE JAVASCRIPTAS$$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) ASINDEX;