CREATE PROC GET_CHARVAL(@STR VARCHAR(100),@GSTR VARCHAR(1))
AS
BEGIN
DECLARE @TEMP TABLE (RID INT IDENTITY, TCHAR VARCHAR(5))
DECLARE @CNT INT, @I INT = 1
SELECT @CNT = LEN(@STR)
WHILE(@I <= @CNT)
BEGIN
INSERT INTO @TEMP
SELECT SUBSTRING(@STR,@I,1)
SET @I = @I + 1
END
SELECT TCHAR, COUNT(1) NOC FROM @TEMP
WHERE TCHAR = @GSTR
GROUP BY TCHAR
END
EXEC GET_CHARVAL 'SREESATYASAIBABA', 'E'
No comments:
Post a Comment