I need to run an UPDATE
statement over multiple records in an ORDER BY
series. This is because my update includes a scalar function, which uses the early updated value. Can anyone suggest a better way other than looping through in the desired order?
Sorry I should have done it very earlier, The Scenario is..
My problem was I have a table variable and it has hierarchical records,
ID SlNo result
1 1.0 True
2 1.1 True
3 1.1.1 True
4 1.1.2 False
5 1.2 True
6 1.2.1 False
7 1.2.2 False
8 1.2.3 False
9 1.2.4 False
And the tree structure is,
1.0
1.0 > 1.1
1.0 > 1.1 > 1.1.1
1.0 > 1.1 > 1.1.2
1.0 > 1.2
1.0 > 1.2 > 2.2.1
1.0 > 1.2 > 2.2.2
1.0 > 1.2 > 2.2.3
1.0 > 1.2 > 2.2.4
I want to update the results to a table and if all the child branches are "False" then its parent should go as "False". For that I need to update rows in the "descending Order" and also must see all its child branches are "False". Can i do it in a single update statement? How can I say Order by in My Update Query?