Script for getting all the numbers from string
DECLARE @string1 varchar(100)='welcome2sql1239hello23';
DECLARE @string2 varchar(100)='',@i int=0;
WHILE @i<=LEN(@string1)
BEGIN
IF(SUBSTRING(@string1,@i,1)>='0' AND SUBSTRING(@string1,@i,1)<='9')
SET @string2=@string2+SUBSTRING(@string1,@i,1);
SET @i=@i+1;
END
SELECT @string2 AS [Numbers obtained];
0 comments:
Post a Comment