I have a large list of IDs that I need to check against a table to see wich onec that are not in my table.
I wrote this query:
SELECT id
FROM ( VALUES (1,2,3,4...) AS Checking (id)
WHERE id NOT IN (SELECT UniqueActivityID
FROM UserActivity
WHERE CONVERT(DATE,[Date]) > CONVERT(DATE,'2015-06-24')
)
The problem is that the query times out because of the large amount of numbers (20'000) and/or table size (+2 million rows). Can I do this in a better, less damanding way?