There is no need to use subquery to determine whether orderlinenumber
exists in another table. Just do UPDATE after LEFT JOIN the two tables will be fine, check this:
UPDATE A
SET A.oliExists = CASE WHEN B.orderlineid IS NULL THEN 'False' ELSE 'True' END
FROM [dbo].[_______Test] AS A LEFT JOIN (SELECT DISTINCT orderlineid FROM [Li]) AS B
ON A.orderlinenumber = B.orderlineid
Best regards,
Cosmog Hong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.