vendredi 14 avril 2023

T-SQL function that return random huge Int

I need to prepare function that will return random quite a huge int. I'm using "huge" adjective to not mix with bigint.

CREATE FUNCTION fn_RandomHugeInt() 
RETURNS int 
AS
BEGIN 
    RETURN (SELECT ABS(CHECKSUM(NEWID()) % (2147483647 - 2000000000 + 1)) + 2000000000)
END

SELECT fn_RandomHugeInt()

Unfortunately it seems that that such code doesn't work




Aucun commentaire:

Enregistrer un commentaire