CREATE FUNCTION extractInteger(@string VARCHAR(2000)) RETURNS VARCHAR(2000) 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