Greetings,
Okay, for you fellow SQL geeks:
SQL (or, at least, Microsoft/T-SQL) does not allow you to use rand() in a user-defined function, at least as of 2008 R2. It's non-deterministic, I get it, no problem.
Here's the thing, though: if I pass a seed, such as rand(123456), it's no longer non-deterministic! It'll always return the same value!
So, what's the deal? It sounds like a bug to me that, when you pass a seed into a rand() function in a UDF, you still get an "Invalid use of a side-effecting operator 'rand' within a function" error. Am I right that the error is arbitrary and a mistake, or am I missing something?
Thanks, everyone.
Okay, for you fellow SQL geeks:
SQL (or, at least, Microsoft/T-SQL) does not allow you to use rand() in a user-defined function, at least as of 2008 R2. It's non-deterministic, I get it, no problem.
Here's the thing, though: if I pass a seed, such as rand(123456), it's no longer non-deterministic! It'll always return the same value!
So, what's the deal? It sounds like a bug to me that, when you pass a seed into a rand() function in a UDF, you still get an "Invalid use of a side-effecting operator 'rand' within a function" error. Am I right that the error is arbitrary and a mistake, or am I missing something?
Thanks, everyone.