Results 1 to 3 of 3

Thread: delete all Product's from selected manufactures?

  1. #1
    Join Date
    Mar 2009
    Posts
    100

    Default delete all Product's from selected manufactures?

    Hello, does anyone know a quick sql query that will let me delete all Product's from selected manufactures?

  2. #2
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    330

    Default

    WARNING: TAKE A BACKUP OF YOUR PRODUCTION DATABASE BEFORE YOU DO THIS AND ALSO TRY THIS ON A DEVELOPMENT DATABASE FIRST!

    If you know your ManufacturerID's then it shouldn't be too difficult:

    Code:
    DELETE FROM [ProductView] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductVector] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductStore] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductLocaleSetting] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductGenre] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductDistributor] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductCustomerLevel] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductAffiliate] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductSection] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductCategory] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductVariant] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [Product] WHERE [ProductID] IN (SELECT [ProductID] FROM [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3))
    
    DELETE FROM [ProductManufacturer] WHERE [ProductManufacturer] WHERE [ManufacturerID] IN (1,2,3)
    (1,2,3) represents the list of known ManufacturerIDs that you want to delete.

    Other things to consider:
    You might want to do this on the Kit tables aswell. And what about shopping cart tables? Do you really want to delete these products if they exist in either an order or a shopping cart? I wouldn't!

    I've not tried/tested the scripts above, and there may be typo errors.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  3. #3
    Join Date
    Mar 2009
    Posts
    100

    Default

    Thanks for help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •