SUBSTR()

Scalar. Returns a specified number of characters from a specific position within a given string.

Syntax

SUBSTR( string, start [, count] )
Parameters

string

The string.

start

The first character to return (one-based).

count

The number of characters to return. If omitted, returns all characters from start to the end of the string.

Data Types

Return

string

start

count

String

String

Integer

Integer

Example

The following example uses the SUBSTR function to select the fifth and sixth characters of the value in the LastName column:

INSERT INTO OutStream
SELECT SUBSTR(Employees.LastName, 5, 2)
FROM Employees;

If the value were "Johnson", the returned value would be "so".