There are 2 easy ways to do what you want.
The first is to use a
Subquery; which in your case gets all of the PartIDs from #Tradecode and removes it from the main query (#Parts) results
Subqueries (SQL Server) - SQL Server | Microsoft Docs[
^]
SELECT PartID, SupplierId
FROM #Parts
WHERE PartID NOT IN (SELECT PartID FROM #TradeCodes)
The other method is to use an
OUTER JOIN between those two tables, and choose to show only those records from #Parts that do not have a match in #Tradecodes.
Outer Joins - SQL Server | Microsoft Docs[
^]
SELECT p.PartID, p.SupplierId
FROM #Parts p
LEFT OUTER JOIN #TradeCodes t ON p.PartID = t.PartID
WHERE t.PartID IS NULL
I would recommend that you read through both of the referenced articles to that you understand how these items work.
When you have 2 or more possible queries which will do the same thing, I would recommend using your IDEs (eg SSMS) tools to see which query is more efficient ("Show Actual Execution Plan"); and obviously choose the more efficient one.
For this case, they are near equal in performance.