Let's say I have a table, Product
, with a column called ProductName
, with values like:
Lawnmower
Weedwacker
Backhoe
Gas Can
Batmobile
Now, I have a list, in Notepad, of products that should be excluded from the result set, i.e.:
Lawnmower
Weedwacker
Batmobile
In my real-life problem, there are tens of thousands of records, and thousands of exclusions. In SQL Studio Manager, how can I construct a query similar to the following pseudocode that will just return Backhoe
and Gas Can
as results?:
declare @excludedProductNames varchar(MAX) =
'Lawnmower
Weedwacker
Batmobile'
SELECT ProductName FROM Product
WHERE ProductName isn't in the list of @excludedProductNames
This is just a one-time report, so I don't care about performance at all.