Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

update openquery remote table with join

$
0
0

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):

updateopenquery(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


ab

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>