I have a requirement to report data back from a SQL table based on a list of key values (EIBItemID), I can just paste these into a query like this
select *
from dbo.SupplyChain_1000469
where EIBItemID in (421290,421316, and so on)
But if this returns fewer results than I am providing I need a quick way to report where the EIBItemID doesn't exist in the table, I could have thousands of these keys to search for but want to avoid creating a table each time for each list when it is easier to just paste them into a query.
I've tried putting the records into a temp table and then doing a join like this
DROP TABLE #EIBItemIDs
CREATE TABLE #EIBItemIDs (EIBItemID INT)
INSERT INTO #EIBItemIDs (EIBItemID)
VALUES (00481771), (00481772), (00481773)
SELECT v.EIBItemID
FROM #EIBItemIDs v
LEFT JOIN dbo.SupplyChain_1799 t ON t.EIBItemID = v.EIBItemID
WHERE t.EIBItemID IS NULL
To just find the missing rows but is there a way to use the first query but report for every row (with just nulls if the key doesn't exist)?