CHARINDEX()

From Lianjapedia
Revision as of 10:30, 27 March 2018 by Yvonne.milne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Function to return the starting position of one character expression in another character expression if found

Syntax

CHARINDEX(<expC1>,<expC2>[, <expN>])

See Also

AGGREGATES, AT(), ATNEXT(), CHOOSE(), CLEAR SMARTQUERY, CREATE CURSOR, CREATE TABLE, EXPLAIN, FETCH, INLIST(), INSERT, LEFT(), LIKE(), LOOKUP(), OCCURS(), OPERATORS, PREDICATES, PSEUDO COLUMNS, RAT(), RIGHT(), RLOOKUP(), SET SMARTQUERY, SET SQLROWID, SET XMLFORMAT, STR(), STREXTRACT(), STRTRAN(), STUFF(), SUBSTR(), SYSTEM TABLES, UPDATE

Description

The CHARINDEX() function returns the starting position of the character expression <expC1> in the character expression <expC2>. If <expC1> is not found in <expC2>, CHARINDEX() returns 0. The numeric expression <expN> is the optional starting position for the search.

Example

? charindex("is","This is a test")
          3
 
open database southwind
select charindex(",",notes) from employees
          1
        231
          1
          1
        248
         73
        240
          1
        109