CREATE PROC [DBO].[USP_STRING_PALINDROME](@STRING VARCHAR(20))
AS
BEGIN
DECLARE @I INT =0
DECLARE @S VARCHAR(20) = ' '
DECLARE @LENGTH INT
SELECT @LENGTH=LEN(@STRING)
WHILE (@I<=@LENGTH)
BEGIN
SELECT @S=@S+SUBSTRING(@STRING,LEN(@STRING)-@I,1)
SET @I=@I+1
END
PRINT @S
IF(@S=@STRING)
BEGIN
PRINT 'THE GIVEN STRING IS PALINDROME'
PRINT'THANK YOU'
END
ELSE
BEGIN
PRINT 'THE GIVENSTRING IS NOT PALINDROME'
PRINT'THANK YOU'
END
END
EXEC [USP_STRING_PALINDROME] 'MADAM'
EXEC [USP_STRING_PALINDROME] 'MANJUNATH'
EXEC [USP_STRING_PALINDROME] 'MADAM'
AS
BEGIN
DECLARE @I INT =0
DECLARE @S VARCHAR(20) = ' '
DECLARE @LENGTH INT
SELECT @LENGTH=LEN(@STRING)
WHILE (@I<=@LENGTH)
BEGIN
SELECT @S=@S+SUBSTRING(@STRING,LEN(@STRING)-@I,1)
SET @I=@I+1
END
PRINT @S
IF(@S=@STRING)
BEGIN
PRINT 'THE GIVEN STRING IS PALINDROME'
PRINT'THANK YOU'
END
ELSE
BEGIN
PRINT 'THE GIVENSTRING IS NOT PALINDROME'
PRINT'THANK YOU'
END
END
EXEC [USP_STRING_PALINDROME] 'MADAM'
EXEC [USP_STRING_PALINDROME] 'MANJUNATH'
EXEC [USP_STRING_PALINDROME] 'MADAM'
No comments:
Post a Comment