G Bryant McClellan (7/3/2012)
Excellent post, both for the concise definitions and the code explanations.
For the Poisson distributions consider the use of a CLR. That my eliminate the side-effects issue.
There is a way to generate the Poisson using Knuth's algorithm in a stored procedure, however it is then awkward to do anything with the results because you'd need to do something like this:
INSERT INTO #MyPoisson (SeqNo, URN, PoissonRN)
EXEC RN_POISSON RAND(CHECKSUM(NEWIDE())), 1000000
So probably your suggestion of using a CLR, provided there is no other alternative than Knuth, is probably a good suggestion. Does this mean you're volunteering one? Inquiring minds want to know. 😛
Thanks for stopping by!
My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]
My thought question: Have you ever been told that your query runs too fast?
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]