mo-mhi :
Based on Itzik Ben-Gan's article in ITProToday
Microsoft’s implementation follows the physical data independence principle, and therefore does not guarantee that you will get the data back from a query in any particular order unless you add an ORDER BY clause in the outer query. A similar violation of the principle is when people update data and the solution’s correctness relies on the data being updated in clustered index order (do a Web search on “quirky update” to see what I mean).
I tried to find what a quirky update means but in vain. I am looking for an example to understand the concept.
David Browne - Microsoft :
Here's an example of the "Quirky Update"
use tempdb
go
drop table if exists t
go
create table t(id int primary key, Amount int, RunningTotal int)
insert into t(id,Amount,RunningTotal) values (1,4,0),(2,2,0),(3,6,0)
declare @t int = 0
update t set @t = RunningTotal = @t + Amount
select * from t
outputs
id Amount RunningTotal
----------- ----------- ------------
1 4 4
2 2 6
3 6 12
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=404928&siteId=1