Udostępnij za pośrednictwem


REVERSE (Transact-SQL)

Returns the reverse of a character expression.

Topic link iconTransact-SQL Syntax Conventions

Syntax

REVERSE ( character_expression )

Arguments

  • character_expression
    Is an expression of character data. character_expression can be a constant, variable, or column of either character or binary data.

Return Types

varchar or nvarchar

Remarks

character_expression must be of a data type that is implicitly convertible to varchar. Otherwise, use CAST to explicitly convert character_expression.

Examples

The following example returns all contact first names with the characters reversed.

USE AdventureWorks;
GO
SELECT FirstName, REVERSE(FirstName) AS Reverse
FROM Person.Contact
WHERE ContactID < 5
ORDER BY FirstName;
GO

Here is the result set.

FirstName      Reverse
-------------- --------------
Catherine      enirehtaC
Gustavo        ovatsuG
Humberto       otrebmuH
Kim            miK
(4 row(s) affected)

See Also

Reference

CAST and CONVERT (Transact-SQL)
Data Types (Transact-SQL)
String Functions (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance