call.copse wrote:Jeff Moden wrote:
Heh... I wonder how many people actually got this question right without having to run the code?
Even I knew about quirky update and I'm only a lowly developer. Surprised Steve wasn't familiar, guess it's a bit niche.
You, good Sir, are neither "only" nor "lowly". 😀
Jeff Moden has noticed me! Sorry, I'm not some kind of fanboi but that has made my (extremely unpleasant otherwise) day.
This is fun code to test and try to get ones head around - in which orders are operators applied.DECLARE @i INT=0;
UPDATE t SET @i = id = @i + 1
Just be careful with that. It's not guaranteed to work in the proper order without following some pretty strict rules.
Change is inevitable... Change for the better is not.
Interesting, but I'd be wary of using it. In a multi-row update, the result is pretty much undefined, unless all the rows are updated to the same value. And in that case, there isn't much point in the approach anyway, unless you really want to confuse the reader...
I have used this to capture intermediate calculations that were used in subsequent calculations in the same row of data. I wish I could find the thread here on SSC that I did this to help on OP, but it was so long ago.
That was interesting!
MCITP:Database Developer 2008
MCTS: SQL Server 2008, Implementation and Maintenance
MCSE: Data Platform
Viewing 4 posts - 16 through 18 (of 18 total)