h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Extract Number from string in SQL

Extract number from string in SQL
CREATE FUNCTION ExtractInteger(@String VARCHAR(2000))
 RETURNS VARCHAR(1000)
 AS
BEGIN DECLARE
@Count INT
DECLARE @IntNumbers VARCHAR(1000)
SET @Count = 0
SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1)
 END SET @Count = @Count + 1
END RETURN @IntNumbers
END
GO