Skip to main content
Q- Reverse a string without using reverse function.

A-declare @Result varchar (max)
declare @string varchar (50) = 'ABHISHEK'
 DECLARE @i int  
   
  SET @Result=''  
  SET @i = 1  
  WHILE @i <= LEN(@string)  
  begin
    SET @Result = SUBSTRING(@string,@i,1)+ @Result
    SET @i=@i + 1

end
print @Result  

Comments

Post a Comment