SUBSTRING Function (SQL)

Help Contents

Introduction

The SQL SUBSTRING function returns part of another string.

Syntax

primary-function-substring ::=
  SUBSTRING '(' character-string FROM start-position
  [ FOR string-length ] [ USING char-length-units> ] ')'

character-string ::=
  value-expression

start-position ::=
  value-expression

string-length ::=
  value-expression

char-length-units ::=
  CHARACTERS
  | OCTETS

Remarks

The SUBSTRING function returns part of character-string starting from start-position. If string-length is used, the SUBSTRING function returns no more than string-length characters. If string-length is not used, the rest of the characters in character-string are returned.

If either character-string is NULL, or start-position is NULL, or string-length is NULL, the function returns NULL.

If the USING clause is omitted, CHARACTERS is assumed.

Examples

  1. Find all analog tags starting with the word 'Pressure':
    SELECT FullName,Value
    FROM TagDataPointAnalog
    WHERE SUBSTRING( Name FROM 1 FOR 8 ) = 'Pressure' 

Further Information

Value Expressions (SQL)

To learn more about SQL scalar value expressions.

Fernhill SCADA Structured Query Language (SQL)

To learn more about the SQL features in Fernhill SCADA.

Glossary

For the meaning of terms used in Fernhill SCADA.