Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 3 of 3

Thread: delete all Product's from selected manufactures?

  1. #1
    deselt is offline Senior Member
    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
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    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
    deselt is offline Senior Member
    Join Date
    Mar 2009
    Posts
    100

    Default

    Thanks for help.