CHARINDEXSTD has a different parameter order than CHARINDEX to align to other SQL syntaxes.
Returns the position of the specified character or sequence. Zero (0) is returned if the string given as search parameter does not exist. The optional start_position parameter specifies the position in the string to start searching.
Syntax:
CHARINDEXSTD (search_for, string_to_search [,start_position])
Example:
/* returns 3 as it is the first occurrence of the character 'c' in the string */SELECT CHARINDEXSTD ('c','abcda1234')
/* returns 5 as the first occurrence of 'a' on or after position 2 is on position 5 in the string */SELECT CHARINDEXSTD ('a','abcda1234',2)
/* returns 0 as the character does exist in the string */SELECT CHARINDEXSTD ('x','abcda1234')

  • No labels