• Jeff Moden (8/3/2015)


    a_ud (8/3/2015)


    Thanks Jeff, perfect solution. Testing it now.

    I also found this explanation, pretty much in the same line, that also seems easy enough:

    http://blog.sqlauthority.com/2012/11/20/sql-server-using-rand-in-user-defined-functions-udf/

    Thanks for the feedback. The problem with RAND() even in that case is that its a fair bit slower than using NEWID() with the CHECKSUM conversion (which converts it to an INT) as a random source and still requires similar calculations to convert it to a domain constrained set of integers.

    And nevermind that RAND() really is not all that random, since it becomes deterministic when I pass it any non-null parameter. But yeah - the perf is also poor :).

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?