Need to update a table from another table which is in one-many relationship. Example as follows:
Table1:
t1_ID t1_Field1
1 null
Table2:
t2_ID t2_Filed1 t1_ID
1 abc 1
2 def 1
t1_ID and t2_ID are primary key with identity attribute respectively. I used an Update statement to update Table1’s t1_Field1:
Update Table1 set t1_Field1=b.t2_Field1 from Table1 a, Table2 b where a.t1_ID=b.t1_ID.
In one environment, it got result as t1_Field1=abc, but in another environment, it is t1_Field1=def. Both environments are SQL Server 2000. I cannot explain why one of them gets the first value from Table2 but the other gets the last value from Table2.
Could anyone help on this? I’ve compared most of the settings for these two servers & databases but cannot find any difference between them. Maybe I am missing some different settings.
Table1:
t1_ID t1_Field1
1 null
Table2:
t2_ID t2_Filed1 t1_ID
1 abc 1
2 def 1
t1_ID and t2_ID are primary key with identity attribute respectively. I used an Update statement to update Table1’s t1_Field1:
Update Table1 set t1_Field1=b.t2_Field1 from Table1 a, Table2 b where a.t1_ID=b.t1_ID.
In one environment, it got result as t1_Field1=abc, but in another environment, it is t1_Field1=def. Both environments are SQL Server 2000. I cannot explain why one of them gets the first value from Table2 but the other gets the last value from Table2.
Could anyone help on this? I’ve compared most of the settings for these two servers & databases but cannot find any difference between them. Maybe I am missing some different settings.