SQL中的反向字符串

时间:2014-06-14 07:27:04

标签: sql sql-server tsql reverse

我试图反转代码,例如: - ABCDEFGHIJKL 我在SQL Server 2005中需要输出为LKJIHGFEDCBA。

我非常感谢任何建议/想法。

3 个答案:

答案 0 :(得分:2)

试试这个:

select reverse('ABCDEFGHIJKL')

答案 1 :(得分:0)

您可以使用Reverse函数来反转字符串。

select reverse('ABCDEFGHIJKL') reverseString

Output will be

reverseString
LKJIHGFEDCBA

or    

SELECT FirstName, REVERSE(FirstName) AS Reverse
    FROM Person.Person
    WHERE BusinessEntityID < 5
    ORDER BY FirstName;

答案 2 :(得分:0)

试试这个:

SELECT REVERSE ('YOURFIELDNAME') AS ReverseString FROM 'YOURTABLE'

REVERSE is a SQL function which will return string containing reverse string of parameter's string. 

如需更多帮助,请查看

http://www.sql-server-helper.com/tips/tip-of-the-day.aspx?tkey=84A7FBB8-D134-482A-8A6A-EA4E660ED51B&tkw=uses-of-the-reverse-string-function