>>The EXISTS operator only checks if there are any records for specified conditions. It cannot return data. I'm not sure why do you need loop in the first place. Try
>>
>>UPDATE r SET NoField = f.Numero
>> FROM Relation r
>>JOIN Field f ON r.Field = f.Field
>>
>>UPDATE r SET NoField2 = f.Numero
>> FROM Relation r
>>JOIN Field f ON r.Field2 = f.Field
>>
>
>Ok, thanks, but I need to apply more logic. So, I need to select the records at first and loop. What adjustment would I need to do to support that?
I think you would need to select them into the cursor then. See DECLARE CURSOR topic in BOL.
If it's not broken, fix it until it is.
My Blog