Code:
INSERT INTO Product_SpecificationAttribute_Mapping
(ProductId, SpecificationAttributeOptionId, AllowFiltering, ShowOnProductPage, DisplayOrder)
SELECT Product.Id AS ProductId, SpecificationAttributeOption.Id AS SpecificationAttributeOptionId, '1' AS AllowFiltering, '0' AS ShowOnProductPage, SpecificationAttributeOption.DisplayOrder AS DisplayOrder
FROM Product
INNER JOIN SpecificationAttributeOption ON ' '+Product.Name+' ' LIKE '% ' + SpecificationAttributeOption.Name +' %'
WHERE SpecificationAttributeId = 7
ORDER BY SpecificationAttributeOption.Name ASC
Ok this is what the data looks like in SpecificationAttributeOption.Name
2002
2001
2000
1999
1998 and so on.
now my Product.Name data looks like:
blah blah Chevy Cavalier 99-03 4 Cyl
so I need the sql statement to trim SpecificationAttributeOption.Name to the last 2 digits and then find recognize the range of years and insert the Id's for 1999,2000,2001,2002 and 2003 all as separate rows for each product. Right now it works for finding the whole year in the product name. Any and all help is appreciated. Thank you!