dwain.c (3/26/2012)
Jeff,The following thought occurred to me last night but I didn't get a chance to test it until this morning.
Isn't the modulo function designed to always return a positive integer?
Hence, in this part of your data generator, I don't believe you need to use ABS:
SomeRandomInteger = CHECKSUM(NEWID()) % @Range + @StartValue
I didn't try it for a million rows but the first 200 came up all as positives.
Apologies, Dwain. I'm not sure how I missed your question on this.
As Michael demonstrated, Modulo will return a negative number if the "Dividend" of the division is negative.
SELECT -1111 % 100,
1111 %-100,
-1111 %-100
----------- ----------- -----------
-11 11 -11
(1 row(s) affected)
--Jeff Moden
Change is inevitable... Change for the better is not.