I'm using NEWID() inside a function. this is my function:
CREATE FUNCTION dbo.myFunc (@newid NVARCHAR(50))
RETURNS int
AS BEGIN
declare @rndValue int
set @rndValue = (SELECT top 1 * FROM #temp ORDER BY lower(@newid))
RETURN @rndValue
END
i have #temp with values: '1','2','3' i want to random from this table using this function. i called this function like this:
dbo.myFunc (NEWID())
but i'm getting every time the same value ('1')
where is my error?