Michael Valentine Jones (3/27/2012)
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.
It's pretty easy to show that the modulus operator will return a negative number:
select x = -1111%100
Results:
x
-----------
-11
Gosh. I'm not sure how I missed Dwain's question. Thanks for the cover, Michael.
--Jeff Moden
Change is inevitable... Change for the better is not.