webCOMAND

SUBSTRING()

Return a portion of a string based on a starting position and optional length.  A starting position of 1 represents the first character.

This function is multi-byte safe.

Prototype

string SUBSTRING(string str, int position[, int length])

Parameters

  • str - The string or expression to evaluate to a string to extract the sub-string from.
  • position - Position from start of str to begin the substring, where 0 is the first character.  If a negative value is provided, the beginning of the substring is position characters from the end of the string, rather than the beginning.
  • length - Optional number of characters from the position to include in the substring.  If no value is provided, all characters through the end of str will be included.

Return

Return the portion of a string starting at position up to the end or optional length characters.

Example

SELECT OID, SUBSTRING(Username, 1, 8) AS FirstEight FROM User