Select b.ItemKey, a.CatKey, a.ParentKey, a.CatName, g.ItemID, c.UserFld1, c.UserFld3, c.UserFld5, f.UOMID, e.SizeValue
From dbo.timWebCategory a Inner JOIN
dbo.timWebCategoryItem b ON a.CatKey = b.CatKey Inner JOIN
mas500_app.dbo.timItem c ON b.ItemKey = c.ItemKey Inner JOIN
dbo.cpsIMItemDetails d ON c.ItemKey = d.ItemKey Inner JOIN
dbo.timItemSize e ON c.ItemKey = e.ItemKey Left JOIN
dbo.timVolumeUOM f ON e.VolUOMKey = f.VolUOMKey Left JOIN
mas500_app.dbo.vWebItem g ON c.ItemKey = g.ItemKey
Where a.Catkey = @Key
AND d.IntFlg = 1
If @color is not Null
Begin
AND c.UserFld1 = @color
End
Order By f.UOMID, e.SizeValue**
Returns this:
Incorrect syntax near the keyword ‘AND’.
Try that…