Script for finding the position of numbers in the given string
DECLARE @input VARCHAR(100)='welcome2Sql376hi975';
DECLARE @output VARCHAR(100)=PATINDEX('%[0-9]%',@input);
DECLARE @position VARCHAR(100)=@output;
WHILE @output<LEN(@input)
BEGIN
SET @input=STUFF(@input,PARSE(@output AS BIGINT),1,'*');
SET @output=PATINDEX('%[0-9]%',@input);
SET @position=@position+','+@output;
END
SELECT @position AS [Positions];
0 comments:
Post a Comment