Forum Discussion
Claudi Magnussen
Jul 04, 2017Copper Contributor
SQL continues excecution when syntax error
Hi.. I have this statement: UPDATE Table1 SET status = 'DoSomething' WHERE status = 'Ready' AND TabId IN (SELECT TabId FROM Table2 WHERE xData IS NOT NULL) . If I run only the subselect I get a...
耕志 馮
Sep 23, 2017Brass Contributor
I recommend that you change the script as below:
UPDATE Table1 SET status = 'DoSomething'
FROM Table1 INNER JOIN Table2 ON Table1.TabId = Table2.TabId
WHERE Table1.status = 'Ready'
AND Table2.xData IS NOT NULL;
This script can not only prevent the incident you have gotten but also validate the relationship between table1 and table2 before updating even though I know tabid only exists in table1....