I agree... the data should be normalized to have one row per control value... it's easier to maintain and, despite the length (# of rows) such a table can get to, it will always be faster than trying to do splits on the fly. Lemme know if you need help converting the control table to a normalized table.
In the meantime, you can always do something like this... without dynamic SQL...
SELECT pc.ProductType_ID, pc.Category
FROM tbl_ProductsCategories pc
INNER JOIN
tbl_Controls tc
ON tc.ControlID = 17
AND ','+CAST(pc.ProductType_ID AS VARCHAR(10))+',' LIKE '%,'+tc.ControlValue+',%'
Like I said, that will be horribly slow compared to a properly normalized table.
--Jeff Moden
|