我想创建在 sql 中返回 1000 到 10000 之间的随机数的函数
我创造了这个
create function dbo.RandomPass()
RETURNS int
as
begin
DECLARE @RETURN int
DECLARE @Upper INT;
DECLARE @Lower INT;
DECLARE @Random float;
set @Random=RAND();
SET @Lower = 1000
SET @Upper = 9999
set @RETURN= (ROUND(((@Upper - @Lower -1) * @Random + @Lower), 0))
return @RETURN
end;
但我得到这个错误
Invalid use of a side-effecting operator 'rand' within a function.