The Site Doctor Blog

Footprints in the snow of a warped mind

< Back to Blog

Quickly delete all products and orders from uCommerce

Note: An updated version of this code for the new Ucommerce schema is available here:

Sometimes you need to blitz your uCommerce database e.g. just before launch or to remove the testing products etc.

This is a quick database clear script which will clear delete all orders and products in uCommerce.

Be careful - this will remove everything without any form of checks (this is the V3 script let me know if you need it for other versions).


DELETE FROM uCommerce_ProductReviewComment
DELETE FROM uCommerce_ProductReview
DELETE FROM uCommerce_OrderLineDiscountRelation
DELETE FROM uCommerce_ShipmentDiscountRelation
DELETE FROM uCommerce_Discount
UPDATE uCommerce_OrderLine SET ShipmentId = NULL
UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL
DELETE FROM uCommerce_Shipment
DELETE FROM uCommerce_OrderAddress
DELETE FROM uCommerce_OrderProperty
DELETE FROM uCommerce_OrderLine
DELETE FROM uCommerce_PaymentProperty
DELETE FROM uCommerce_Payment
DELETE FROM uCommerce_OrderStatusAudit
DELETE FROM uCommerce_PurchaseOrder
DELETE FROM uCommerce_Address
DELETE FROM uCommerce_Customer

DELETE uCommerce_ProductRelation
DELETE uCommerce_ProductProperty
DELETE uCommerce_ProductDescriptionProperty
DELETE uCommerce_ProductDescription
DELETE uCommerce_CategoryProductRelation
DELETE uCommerce_PriceGroupPrice
DELETE FROM uCommerce_Product

-- Just double check things have gone
SELECT * FROM uCommerce_PurchaseOrder o
SELECT * FROM uCommerce_Product p

-- For safety's sake, run it in a transaction just in case you change your mind
-- When happy it works, uncomment this line and comment out the ROLLBACK
Author: Tim on

Liked this post? Got a suggestion? Leave a comment