Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to update value from another TSQL

I have to update value based on values from another table:

update OracleOb..NS.myTable set name = (select name from myTable1 where id = 1)
   where id = 1

here the SQL has some problem. How can I get value from myTable1 and set it to myTable?

I am using MS SQL 2005.

Sorry I have to edit this question again. The table myTable is a linked object of Oracle table. I tried the suggested answer but I got error message:

 The OLE DB provider "OraOLEDB.Oracle" for linked server "OracleOb" reported an error. The provider reported an unexpected catastrophic failure.
like image 275
David.Chu.ca Avatar asked Dec 14 '22 03:12

David.Chu.ca


1 Answers

UPDATE m 
SET m.name = m1.name
FROM MyTable m
    JOIN MyTable1 m1 ON m.id = m1.id
WHERE m.id = 1
like image 188
AdaTheDev Avatar answered Dec 28 '22 23:12

AdaTheDev