@MS SQL Server has lost all credibility. #
Posted Wednesday 6th August 2008 23:24 GMT
Very interesting but a bit misleading. If you use functions like newid() [*] in select statements of any complexity then you can expect some odd behaviour, although I didn't realise to what extent.
Simple fix: don't use non-deterministic expressions in select statements. I never have (and now I never will, thanks to your link).
The problem isn't one of implementation but MS getting sloppy in design. They should never have allowed such 'functions' to be used in such contexts at all until they'd thought it through properly. Any decent mathematician would have pointed out the problems sharpish and warned against it.
That said, the fact that:
"Actually, if you experiment, you can devise others - for example, short-circuit evaluation of AND clauses: make the second clause throw an arithmetic divide-by-zero - different optimizations may execute that second clause BEFORE the first clause"
bloody hell. They never did document whether boolean ops were short-circuit or not (I looked), and it comes out on a blog. Considering the quality of the rest of their documentation, that's an amazing slip.
[*] a rather non-functional function, mathematically speaking, in that it's result aren't guaranteed to be the same each time it's called for the same arguments.