| Author |
Topic  |
|
|
deanglen
Starting Member
40 Posts |
Posted - 08/08/2012 : 05:45:15
|
Hi The SQL below forms part of an XML Feed file for Google. Do you know if it is possible to change the SQL so that it DOES NOT include products that have an empty description?
<sql> <![CDATA[ select p.productid, p.name, isnull(pv.name, '') VariantName, p.description, p.sename, p.ImageFileNameOverride, p.SKU, isnull(p.FroogleDescription, '') ProductFroogleDescription, p.SEKeywords, m.Name brand, p.ManufacturerPartNumber, pv.price, isnull(pv.saleprice, 0) saleprice, isnull(pv.FroogleDescription, '') VariantFroogleDescription, isnull(pv.description, '') VariantDescr, pv.inventory, ROW_NUMBER() OVER (ORDER BY p.productid) AS ROW from dbo.product p join dbo.productvariant pv on p.productid = pv.productid join dbo.ProductManufacturer pm on pm.ProductID = p.ProductID join dbo.Manufacturer m on m.ManufacturerID = pm.ManufacturerID join dbo.ProductStore ps on ps.ProductID = p.ProductID and ps.StoreID = 1 left join (select variantid, sum(quan) inventory from dbo.inventory group by variantid) i on pv.variantid = i.variantid where p.IsSystem=0 and p.deleted = 0 and p.published = 1 and p.ExcludeFromPriceFeeds = 0 and pv.isdefault = 1 and case p.TrackInventoryBySizeAndColor when 1 then isnull(i.inventory, 0) else pv.inventory end >= @HideProductsWithLessThanThisInventoryLevel ]]> </sql> |
|
|
sunitabeck
Flowing Fount of Yak Knowledge
5152 Posts |
Posted - 08/08/2012 : 06:56:49
|
quote: Originally posted by deanglen
Hi The SQL below forms part of an XML Feed file for Google. Do you know if it is possible to change the SQL so that it DOES NOT include products that have an empty description?
<sql> <![CDATA[ select p.productid, p.name, isnull(pv.name, '') VariantName, p.description, p.sename, p.ImageFileNameOverride, p.SKU, isnull(p.FroogleDescription, '') ProductFroogleDescription, p.SEKeywords, m.Name brand, p.ManufacturerPartNumber, pv.price, isnull(pv.saleprice, 0) saleprice, isnull(pv.FroogleDescription, '') VariantFroogleDescription, isnull(pv.description, '') VariantDescr, pv.inventory, ROW_NUMBER() OVER (ORDER BY p.productid) AS ROW from dbo.product p join dbo.productvariant pv on p.productid = pv.productid join dbo.ProductManufacturer pm on pm.ProductID = p.ProductID join dbo.Manufacturer m on m.ManufacturerID = pm.ManufacturerID join dbo.ProductStore ps on ps.ProductID = p.ProductID and ps.StoreID = 1 left join (select variantid, sum(quan) inventory from dbo.inventory group by variantid) i on pv.variantid = i.variantid where p.IsSystem=0 and p.deleted = 0 and p.published = 1 and p.ExcludeFromPriceFeeds = 0 and pv.isdefault = 1 and case p.TrackInventoryBySizeAndColor when 1 then isnull(i.inventory, 0) else pv.inventory end >= @HideProductsWithLessThanThisInventoryLevel ]]> </sql>
Add another condition to the where clause as shown below:....
AND CASE p.TrackInventoryBySizeAndColor
WHEN 1 THEN ISNULL(i.inventory, 0)
ELSE pv.inventory
END >= @HideProductsWithLessThanThisInventoryLevel
AND NULLIF(p.description,'') IS NOT NULL
.... |
 |
|
|
deanglen
Starting Member
40 Posts |
Posted - 08/08/2012 : 07:13:06
|
Thanks I tried but but get
Exception=The data types ntext and varchar are incompatible in the equal to operator.<br/>
|
 |
|
|
sunitabeck
Flowing Fount of Yak Knowledge
5152 Posts |
Posted - 08/08/2012 : 07:17:22
|
Change it to:AND NULLIF(CAST(p.description AS VARCHAR(MAX)),'') IS NOT NULL |
 |
|
|
deanglen
Starting Member
40 Posts |
Posted - 08/08/2012 : 07:24:45
|
| Fixed it! THanks! |
 |
|
|
banwuin1
Starting Member
1 Posts |
Posted - 08/08/2012 : 23:27:53
|
Thank you for this article.Really impressed! Everything is very, very clear, open is a description of the problem. It contains the information.
unspammed john andy |
 |
|
| |
Topic  |
|
|
|