我想在不使用反向命令的情况下反转给定的字符串是SQL any
答案
反向('串样本)
来自emp
答案 0 :(得分:0)
由http://www.c-sharpcorner.com/code/1308/reverse-string-in-sql-server-without-reverse-function.aspx提供,但使用SQL Server
CREATE function StringReverse(@inputstring varchar(max))
returns varchar(max)
AS
BEGIN
DECLARE @i int,
@Result varchar(max)
SET @Result=''
SET @i = 1
WHILE @i <= LEN(@inputstring)
BEGIN
SET @Result = SUBSTRING(@inputstring,@i,1) + @Result
SET @i=@i + 1
END
RETURN @Result
END