how to write stored procedure for reverse string dynamically
how to write stored procedure for reverse string dynamically
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prasham SabadraPosted Feb 22, 2015, 12:09 AM
Never tried but please check once - http://stackoverflow.com/questions/11930925/reversing-a-string-using-teradata-spl
Joginder BangerPosted Feb 21, 2015, 2:12 PM
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