I am trying to create a user defined function which calls the system RAND() function inside it, when I try to create the function it errors out with the followi
Just pass RAND() value as parameter from outside:
CREATE FUNCTION getNumber(@_id int, @RAND FLOAT)
RETURNS DECIMAL(18,4)
AS
BEGIN
DECLARE @RtnValue DECIMAL(18,4);
SELECT TOP 1 @RtnValue = EmployeeID
FROM dbo.Employees
ORDER BY EmployeeID DESC
SET @RtnValue = @RAND * @RtnValue * (1/100)
RETURN @RtnValue;
END
And call as getNumber(10, RAND())
No any side effects.