REMBYTES

The REMBYTES function removes one or more bytes from a text expression and returns the value that remains.

Return Value

TEXT

Syntax

REMBYTES(text-expression start [length])

Arguments

text-expression

The expression from which REMBYTES removes bytes. When the characters to be removed from text-expression contain embedded line breaks, these breaks are also removed. Other line breaks are preserved. Removed line breaks are not counted toward the total number of characters removed.

start

An integer that represents the character position at which to begin removing characters. The position of the first character in text-expression is 1. When the value of start is greater than the length of text-expression, REMBYTES simply returns text-expression.

length

An integer that represents the number of characters to be removed. When length is not specified, only the character at start is removed.

Notes

Single-Byte Characters

When you are using a single-byte character set, you can use the REMCHARS function instead of the REMBYTES function.

NTEXT Data Type

This function does not accept NTEXT arguments, because it is oriented toward byte-manipulation instead of character manipulation. It always returns values of type TEXT. When you must use this function on NTEXT values, use the CONVERT or TO_CHAR function to convert the NTEXT value to TEXT.

Examples

Example 20-15 Using REMBYTES to Remove a Substring

This example shows how to remove the substring there from the text value hellotherejoe.

The statement

SHOW REMBYTES('hellotherejoe', 6, 5)

produces the following output.

hellojoe

Example 20-16 Removing a Single Byte

This example shows how to remove the character t from the text value hellotherejoe.