CREATE FUNCTION [dbo].[ocms_fn_randbetween](@bottom integer, @top integer) RETURNS integer AS BEGIN RETURN (select cast(round((@top-@bottom) * [rn] +@bottom,0) as integer) from [dbo].[ocms_fn_rand]) END