ALTER FUNCTION dbo.ufn_GetNumber(@AData VARCHAR(256))RETURNS VARCHAR(50)AS BEGIN DECLARE @I INT; DECLARE @COUNT INT; DECLARE @ILEN INT; DECLARE @AValue VARCHAR(50); SELECT @COUNT = 0, @I = 1, @ILEN = LEN(@AData), @AValue = ''; WHILE (@I <= @ILEN) BEGIN IF (SUBSTRING(@AData, @I, 1) >= '0') AND (SUBSTRING(@AData, @I, 1) <= '9') SELECT @COUNT = @COUNT + 1; ELSE SELECT @COUNT = 0; IF (@COUNT >= 3) BEGIN SELECT @AValue = SUBSTRING(@AData, @I - 1, 1) BREAK; END; SELECT @I = @I + 1 END; RETURN SUBSTRING(@AData, @I - 1, 1); END;SELECT dbo.ufn_GetNumber(COLUMN_NAME) FROM TABLE_NAME