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

Thread: SQ Query for Product Distributors

  1. #1
    joecalardo is offline Member
    Join Date
    May 2011
    Posts
    61

    Default SQ Query for Product Distributors

    Hello, does anyone know a quick sql query that will let me delete the distributor ID's from my Product's and insert new ones, I am trying to change a few things doing a mass upload via excel copy and paste.

    If BFG is there ? Maybe you can help me out ?! :-P

    Basically ... ProductID is A2, DistributorID is B2 . Thanks! Need a quick copy down and paste statement.

    Thanks!

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

    Default

    Something like this - (untested)...

    C#/VB.NET Code:
    ="UPDATE ProductDistributor SET DistributorID = "&B2&" WHERE ProductID = "&A2&";" 


    TTFN

    BFG

  3. #3
    joecalardo is offline Member
    Join Date
    May 2011
    Posts
    61

    Default

    Damnit, no good. Gave me this for some products

    Violation of PRIMARY KEY constraint 'PK_ProductDistributor'. Cannot insert duplicate key in object 'dbo.ProductDistributor'.
    The statement has been terminated.


    :-\ Any other suggestions ? Would doing a Delete from and then insert into statement posisbly work ?

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

    Default

    Did you copy & paste that exactly?

    I can't see how updating the DistributorID in that table could ever give you that error message.



    TTFN

    BFG

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

    Default

    It only means that the row with the unique combination of ProductID and DistributorID already exists. You cannot have 2 records with those being the same in the db.
    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!

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

    Default

    & when you're only updating the DistributorID of an already existing row, this error shouldn't appear...