CREATE PROC [DBO].[USP_REVERSESTRING](@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
END
EXEC [USP_REVERSESTRING] 'MANJUNATH'
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
END
EXEC [USP_REVERSESTRING] 'MANJUNATH'
No comments:
Post a Comment