I am trying to create an update query and making little progress in getting the right syntax. The following query is working:
SELECT t.Index1, t.Index2, COUN
Doing a left join with a subquery will generate a giant temporary table in-memory that will have no indexes.
For updates, try avoiding joins and using correlated subqueries instead:
UPDATE
Table AS t
SET
t.SpecialEventCount = (
SELECT COUNT(m.EventType)
FROM MEvents m
WHERE m.EventType in ('A','B')
AND m.Index1 = t.Index1
AND m.Index2 = t.Index2
)
WHERE
t.SpecialEventCount IS NULL
Do some profiling, but this can be significantly faster in some cases.