TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Reverse String In SQL Server Without REVERSE Function
Govinda Rajulu Yemineni
Jul 13
2015
Code
18.7
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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
Execution of Function:
select
dbo.StringReverse(
'xyz123abc'
)
Result:
cba321zyx
Reverse String
SQL Server
REVERSE Function