How to write stored procedure for reverse string dynamically
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Joginder BangerRank #360 · 7K reputationPosted Feb 21, 2015, 9:12 AM EST
as
begin
DECLARE @temp int;
DECLARE @ret varchar(max)
set @temp=len(@value)
while(@temp>0)
begin
if(@ret is null)
begin
set @ret= SUBSTRING(@value,@temp,1)
end
else
begin
set @ret+= SUBSTRING(@value,@temp,1)
end
set @temp-=1
end
select @ret
end
when run this store procedure I got result like this type.
DECLARE @return_value int
EXEC @return_value = [dbo].[reverseStringVal]
@value = N'aidni ym evol I'
SELECT 'Return Value' = @return_value
GO
output is
I love my india
Prasham SabadraRank #116 · 19.3K reputationPosted Feb 21, 2015, 7:09 PM EST
Never tried but please check once - http://stackoverflow.com/questions/11930925/reversing-a-string-using-teradata-spl