Select insert into composite primary key tables

39 Views Asked by At

I have a table with a composite primary key of 3 values:

SELECT sifra_kapit_proj,
       sifra_aktivnosti,
       sifra_funkcije,
       naziv_aktivnosti,
       row_version,
       sifra_programa
  FROM EFIN00123..aktivnost

The 3 starting with sifra_ are the primary key. I need to equalize the content from this table and the same table in another database (any rows from table 2 that aren't in table 1 need to be inserted). Normally, I'm doing an insert into select along the primary key, but it won't work here.
How to go around doing that?

For clarification, how I normally go around equalizing tables. This does not work since both tables have the exact same sifra_aktivnosti (or any of the other two values), but have different total number of rows

insert into EFIN00123..aktivnost
select sifra_kapit_proj,sifra_aktivnosti, sifra_funkcije, naziv_aktivnosti,
row_version, sifra_programa
from EKUF00123..aktivnost where sifra_aktivnosti not in
( select sifra_aktivnosti from EFIN00123..aktivnost )```
0

There are 0 best solutions below