M
M
MixanMM2021-12-13 07:08:36
SQL Server
MixanMM, 2021-12-13 07:08:36

Update in linked server table between MSSQL and POSTGRESS?

Good time everyone, please tell me in this survey:
There is a table in the database on the MSSQL 2008 server, the POSTGRESS database is connected to it through a linked server, I'm trying to update the data in the table like this:

UPDATE openquery(MOB, 'select amount from account_balance')
SET amount=bal
FROM openquery  (MOB, 'select amount, account_barcode from account_balance') rem_k 
JOIN (SELECT [general].[dbo].[account].bal, [general].[dbo].[account].barcode FROM [general].[dbo].[account])
[account] ON  rem_k.account_barcode=barcode


But this query updates all records with the same number in all values, although if you make a query like this:
SELECT rem_k.amount, rem_k.account_barcode, [general].[dbo].[account].bal
FROM openquery  (MOB, 'select amount, account_barcode from account_balance') rem_k 
LEFT OUTER JOIN
[general].[dbo].[account] ON  rem_k.account_barcode=[general].[dbo].[account].barcode
ORDER BY barcode

Then it displays the data correctly, tell me how to update it correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2021-12-13
@MixanMM

openquery and update

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question