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 5 of 5

Thread: SQL To Set all products to a specific customer level

  1. #1
    ryanneves@nevesmedia.com is offline Junior Member
    Join Date
    Feb 2008
    Posts
    4

    Default SQL To Set all products to a specific customer level

    I have a customer level all customers get set to after login, my customer has not set new products in the database for the last 2 years to that customer level when adding them. it's customer level id is 2, so is there an SQL command that works on version 7.0.2.5 that will go through all products and add the customer level 2 to each product in the database?

    thanks,

  2. #2
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    This should do it :-

    Code:
    DELETE FROM dbo.ProductCustomerLevel WHERE CustomerLevelID = 2; 
    INSERT INTO dbo.ProductCustomerLevel (ProductID, CustomerLevelID) SELECT ProductID, 2 from dbo.Product;

    TTFN

    BFG

  3. #3
    ryanneves@nevesmedia.com is offline Junior Member
    Join Date
    Feb 2008
    Posts
    4

    Default

    what does the delete line do, would just the second line work if I just want every product in the database to now have the checkmark for the customer level 2 beside it?

    thanks for the help.

  4. #4
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    The delete clears out all of the old links first. Otherwise you might/would end up with errors. There are many different ways of doing the same thing. It's easier than trying to add only ones that are missing.

    Run the script - it's solid advice. Of course, you should do this in a test environment first to be sure you achieve the results you are expecting.
    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!

  5. #5
    ryanneves@nevesmedia.com is offline Junior Member
    Join Date
    Feb 2008
    Posts
    4

    Default

    worked great thanks.