Monday, 12 August 2013

Polyndrom in sql

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

No comments:

Post a Comment

EMP, DEPT Sample script

/****** Object:  Table [dbo].[DEPT]    Script Date: 19-05-2016 06:58:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET A...