Results 1 to 6 of 6

Thread: SQ Query for Product Distributors

Hybrid View

  1. #1
    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
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

    Something like this - (untested)...

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


    TTFN

    BFG

  3. #3
    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
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    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
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    339

    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
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

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

Posting Permissions

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