PRINTING STRING IN REVERSE without using STRING FUNCTION SUBSTRING()
DECLARE @str VARCHAR(20)='vagalla suresh reddy',@oldstr VARCHAR(20),@newstr VARCHAR(20)='',@I INT=1,@C INT=0
SELECT @OLDSTR=@STR,@C=LEN(@STR)
WHILE(@I<=@C)
BEGIN
SELECT @newstr=@newstr+SUBSTRING(@str,@C,1)
SET @C=@C-1
END
PRINT @newstr
ANS:ydder hserus allagav
DECLARE @str VARCHAR(20)='vagalla suresh reddy',@oldstr VARCHAR(20),@newstr VARCHAR(20)='',@I INT=1,@C INT=0
SELECT @OLDSTR=@STR,@C=LEN(@STR)
WHILE(@I<=@C)
BEGIN
SELECT @newstr=@newstr+SUBSTRING(@str,@C,1)
SET @C=@C-1
END
PRINT @newstr
ANS:ydder hserus allagav
No comments:
Post a Comment