Examples
Standards and
compatibility
See also
SUBSTRING function [String]
Function
Syntax
Parameters
Examples
Usage
Standards and
compatibility
See also
The following statement returns the value chocolate pie.
SELECT STUFF( 'chocolate cake', 11, 4, 'pie' )
♦
SQL/92
Vendor extension.
♦
Compatible with Adaptive Server Enterprise.
Sybase
"INSERTSTR function" on page 341
Returns a substring of a string.
{ SUBSTRING | SUBSTR }( string-expression , start [, length ] )
string-expression
The string from which a substring is to be returned.
start
The start position of the substring to return, in characters. A negative
starting position specifies a number of characters from the end of the string
instead of the beginning. The first character in the string is at position 1.
length
The length of the substring to return, in characters. A positive
length specifies that the substring ends length characters to the right of the
starting position, while a negative length specifies that the substring ends
length characters to the left of the starting position.
The following statement returns back:
SELECT SUBSTRING( 'back yard',1 ,4 )
The following statement returns yard:
SELECT SUBSTRING( 'back yard', -1 , -4 )
If length is specified, the substring is restricted to that length. If no length is
specified, the remainder of the string is returned, starting at the start position.
Both start and length can be negative. Using appropriate combinations of
negative and positive numbers, you can get a substring from either the
beginning or end of the string.
If string-expression is of binary data type, the SUBSTRING function
behaves as BYTE_SUBSTR.
♦
Vendor extension.
SQL/92
♦
SUBSTRING is compatible with Adaptive Server Enterprise.
Sybase
SUBSTR is not supported by Adaptive Server Enterprise.
"BYTE_SUBSTR function" on page 317
Chapter 8 SQL Functions
369
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers