Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)

  • RE: RANDom traps for the unwary

    Jeff Moden (5/10/2016)


    Heh... absolutely correct. It doesn't happen often but it does happen.

    Scientists have calculated that the chance of anything so patently absurd actually existing are millions...

  • RE: RANDom traps for the unwary

    Sioban Krzywicki (5/9/2016)

    I'd rather do this

    SELECT (ABS(CAST(CHECKSUM(NewID()) AS bigint)) %20) + 1

    than divide by 10. Matter of preference, really.

    Also correct, but to get value from range <1,20> you cast it...

  • RE: RANDom traps for the unwary

    Sioban Krzywicki (5/9/2016)


    I believe I saw Jeff Moden of these forums post a simple, truly random generator.

    SELECT (ABS(CHECKSUM(NEWID())) %20) + 1

    This generates random numbers between 1 and 20. To have...

  • RE: RANDom traps for the unwary

    SELECT *

    FROM Person.StateProvince

    WHERE (ABS(CAST((BINARY_CHECKSUM(*) * RAND()) AS INT)) % 100) < 10

    What happens if CAST((BINARY_CHECKSUM(*) * RAND()) AS INT = - 2^31 ?

    Int Range is <-2 147 483...

Viewing 4 posts - 1 through 4 (of 4 total)