I have two sets of data I'm trying to join, but the query is so slow it times out even with very small sections of the data.
The first set of data is an email address and a comma-separated list of categories.
The second set of data is a list of SKUs which have one category ID associated with them on each row:
I've tried to create join the two result sets on a LIKE condition
(SELECT EmailAddress, Customer_Categories FROM Customers) AS CustomerTable
(SELECT ProductCode, CategoryID FROM Products) AS ProductTable
CustomerTable.Customer_Categories LIKE ProductTable.CategoryID
but either there's too much data, the query is too slow, or both. Is there a better or more efficient way to do this sort of query in SQL Server?