update openquery remote tabel with join

  • Hi All,

    I have a problem with OPENQUERY update on remote table. I've googled for days, and can't solve the problem.

    Here is the problem:

    Local server MS SQL 2005.

    Remote server: MySQL.

    The linked server is communicating through MySQL ODBC 5.1

    I created the following code for update (tried many other version too, this is the last one):

    update openquery(Remoteserver,'select products_id, products_price, products_last_modified, products_stock from products1')

    set

    products_price=A.products_price,

    products_stock=A.products_stock,

    products_last_modified=getdate()

    FROM

    (select * from vi_products_update) AS A INNER JOIN

    openquery(octopus, 'select products_id from products1')AS B

    ON A.products_id=B.products_id

    When I run the query the columns are updated with the same value, for each record. It looks the value is the first which match the criteria. Each (remote and local) table has as primary key products_id. In this example I used as result set for local a view, but I have the same result if I use a table.

    the products_last_modified column is updated in order, and if I update for e.g. the products_price with a constant that is ok too. The problem should be somewhere with join, but I can' get it where.

    THX for any help

  • What happens if you add to the end...

    where products_id = a.products_id

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply