Running MS SQL Server 2017. I've come across a 'partial' answer to this question but want to go into a bit more detail. I believe, from what I've read, the following code statement is non-deterministic as to what table1.col2 will be set to when table1 has a value of 1 for col1 and table2 has 3 rows with a value of 1 for col1 and 3 different values for col2.
I believe that the answer for my question is, if there is a many-to-many join (e.g. table1 has multiple rows with a value of 1 for col1, will the value of col2 be consistent? I believe it would (e.g. if one row with a value of 1 for col1 gets col2 set to a value of 4, then all rows with a value of 1 for col1 would get col2 set to a value of 4, since the update will be set based).
Neither of these statements are not something that can be easily 'proved' since you need to prove repeatability and how many times do you need to execute code with the same results before you can declare repeatibility? 1,000? 1,000,000? With my luck, the 1,000,001st time would give a different result.
Any internals people out there that would have a definitive answer?
SET col2 = b.col2
FROM table1 a
INNER JOIN table2 b
ON b.col1 = a.col1;