December 17th, 2008

POSITION (start pos. of a string)

The POSITION function returns an integer indicating the first starting position of a string within the search string.
If the search string is not found, zero will be returned.
Format: POSITION(search_string IN full_string)

Example:           POSITION('CADAB' IN 'ABRAH CADABRAH') Result: 7
                   POSITION('CABAD' IN 'ABRAH CADABRAH') Result: 0

> Various RDBMS systems are case sensitive or case insensitive. See the documentation for your system.

> Access uses InStr(start_position, string, substring) to find the beginning and InStrRev() to find the ending count from the end.

> DB2 uses POSSTR(string, substring).

> MySQL supports POSITION.

> Oracle uses INSTR(string, substring).

> SQL Server uses CHARINDEX(substring, string).
SQL Server also uses PATINDEX which allows wildcard characters.

Comments are closed.

Sorry, the comment form is closed at this time.