CREATE VIEW RangeView
AS
SELECT RE = RAND()
CREATE FUNCTION RangeNumber ( @Min INT, @Max INT )
RETURNS INT
AS
BEGIN
DECLARE @R DECIMAL(38, 0)
SELECT @R = ( CAST(RE * ( @Max - @Min ) + @Min AS DECIMAL(38, 0)) )
FROM RangeView
RETURN @R
END