> ## Content Index
> Fetch the complete content index at: https://blog.tsd.digital/llms.txt
> Use this file to discover other available public pages before exploring further.

# Bulk delete products by SKU in uCommerce
- URL: https://blog.tsd.digital/bulk-delete-products-by-sku-in-ucommerce/
- Published: 2014-06-03T18:10:28.000Z
- Updated: 2014-06-03T18:10:28.000Z
- Author: Tim Gaunt
- Tags: SQL, Ucommerce, #Import 2025-04-01 05:38

You may already have come across my script to [Quickly delete all products and orders from uCommerce](http://blogs.thesitedoctor.co.uk/tim/2013/05/11/Quickly+Delete+All+Products+And+Orders+From+UCommerce.aspx?ref=blog.tsd.digital) but sometimes you need to delete just a set of products by SKU so here's a new one for you

BEGIN TRAN DECLARE @ProductIds TABLE (Id int) INSERT INTO @ProductIds (Id) SELECT p.ProductId FROM uCommerce\_Product AS p WHERE p.Sku IN ('EXAMPLE1','EXAMPLE2') DELETE prc FROM uCommerce\_ProductReviewComment prc JOIN uCommerce\_ProductReview AS pr ON prc.ProductReviewId = pr.ProductReviewId WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE FROM uCommerce\_ProductReview WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE uCommerce\_ProductRelation WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE uCommerce\_ProductProperty WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE pdp FROM uCommerce\_ProductDescriptionProperty pdp JOIN uCommerce\_ProductDescription AS pd ON pdp.ProductDescriptionId = pd.ProductDescriptionId WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE uCommerce\_ProductDescription WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE uCommerce\_CategoryProductRelation WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE uCommerce\_PriceGroupPrice WHERE ProductId IN (SELECT Id FROM @ProductIds) DELETE FROM uCommerce\_Product WHERE ProductId IN (SELECT Id FROM @ProductIds) -- Just double check things have gone SELECT \* FROM uCommerce\_Product p WHERE ProductId IN (SELECT Id FROM @ProductIds) -- For safety's sake, run it in a transaction just in case you change your mind ROLLBACK TRAN -- When happy it works, uncomment this line and comment out the ROLLBACK --COMMIT TRAN