cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA Update Table from 2 different Schema

bogdanbgddm
Explorer
0 Kudos
798

schema.png

I am trying to update TABLE2 from SCHEMA2 with Location values from TABLE1 from SCHEMA1 by SN and DATAID (the combination of SN and DATAID must be the same in order to update the location column) I've used the below code:

UPDATE "SCHEMA2"."TABLE2"
SET "LOCATION" = (SELECT LOCATION FROM "SCHEMA1"."TABLE1") 
WHERE "SN" = (SELECT SN FROM "SCHEMA1"."TABLE1") 
AND "DATAID" = (SELECT DATAID FROM "SCHEMA1"."TABLE1") 

i have the following error: "SAP DBTech JDBC: [305]: single-row query returns more than one row" How can I resolve this?

Many thanks!

View Entire Topic
RichS
Participant
0 Kudos

Have you tried something like this:

UPDATE T2 SET T2."LOCATION" = T1."LOCATION" FROM "SCHEMA2"."TABLE2" T2 JOIN "SCHEMA1"."TABLE1" T1 ON (T1."SN" = T2."SN" AND T1."DATAID" = T2."DATAID")