Ich denke, Abfrage 1 ist besser lesbar als Abfrage 2, aber ich würde gerne wissen, ob es einen Unterschied in Bezug auf die Leistung gibt?SQL Server-Abfrage - Was ist besser in der Leistung?
Abfrage 1
UPDATE table_1
SET col_1 =
CASE WHEN table_1.col_pk IS NULL THEN value1
ELSE value2
END
FROM table_1
LEFT JOIN table_2 ON table_1.col_pk = table_2.col_pk
oder
Abfrage 2
UPDATE table_1
SET col_1 = value1
FROM table_1
LEFT JOIN table_2 ON table_1.col_pk = table_2.col_pk
WHERE table_1.col_pk IS NULL
UPDATE table_1
SET col_1 = value2
FROM table_1
INNER JOIN table_2 ON table_1.col_pk = table_2.col_pk
Benchmark ........... –
'FALL WENN col_pk IS NULL ist, welche von zwei' col_pk'? – anatol
oops sorry .. table_1.col_pk stattdessen. Vielen Dank. Ich werde den Thread aktualisieren. –