Skip to content
SQLSimplified
string

REVERSE()

Returns the characters of a string in reverse order.

Description

REVERSE flips a string so its last character becomes the first. It's useful for palindrome checks, reversing encoded values, or pulling a suffix when you don't know its length (reverse, take from the left, reverse back).

Syntax

REVERSE(string)

Parameters

NameDescriptionOptional
stringThe text to reverse.No

Return Type

Returns a VARCHAR.

Examples

Loading playground environment...
Loading playground environment...

Grab a trailing segment

To take the last N chars without knowing the length: REVERSE(LEFT(REVERSE(s), N)).

Common Mistakes

  • Reversing numbers as text. REVERSE works on strings; cast numbers to text first if you mean to reverse their digits.
  • Expecting word reversal. It reverses characters, not words.
  • Unicode surprises. Some engines reverse by code point, which can look odd for multi-byte characters.

See also: SUBSTRING, LENGTH, CONCAT.

Cite this resource

SQLSimplified. "REVERSE() SQL Function". Available at: https://sqlsimplified.online/reference/reverse