ASA SQL Reference
SQL Functions
Alphabetical list of functions
Returns a substring of a string. The substring is calculated using bytes, not characters.
BYTE_SUBSTR ( string-expression, start [, length ] )
string- expression The string from which the substring is taken.
start An integer expression indicating the start of the substring. A positive integer starts from the beginning of the string, with the first character being position 1. A negative integer specifies a substring starting from the end of the string, the final character being at position -1.
length An integer expression indicating the length of the substring. A positive length specifies the number of bytes to be taken starting at the start position. A negative length specifies the number of bytes to be taken ending at the start position.
If length is specified, the substring is restricted to that number of bytes. Both start and length can be either positive or negative. A negative starting position specifies a number of bytes from the end of the string instead of the beginning. A positive length specifies that the substring ends length bytes to the right of the starting position, while a negative length specifies that the substring ends length bytes to the left of the starting position and ends at the start position. Using appropriate combinations of negative and positive numbers, you can get a substring from either the beginning or end of the string.
SQL/92 Vendor extension.
SQL/99 Vendor extension.
Sybase Not supported in Adaptive Server Enterprise.
The following statement returns the value age .
SELECT BYTE_SUBSTR( 'Test Message',-1,-3 )