How to reverse a string in MS-Sql Server without using REVERSE( ) function
Its simple ,Try following query
its one of the interview question in these days
DECLARE @Result VARCHAR (50)=''
DECLARE @Len INT
SET @Len=LEN (@Str)
WHILE (0<@Len)
BEGIN
SET @Result=@Result+SUBSTRING (@Str,@Len,1)
SET @Len=@Len-1
END
PRINT @Result
OUT PUT :
No comments:
Post a Comment