Insert records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jas2803
    New Member
    • Oct 2007
    • 30

    Insert records

    I have two tables, the first table has 2000+ records the other only has approx 500....two columns as "linked" that is they are the same information.... .PK and date...I would like to insert the remaining 1500+ records into the smaller table.

    what I need is an if not exist in table2 insert new record using table1 values PK, date

    Any Ideas?
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    a- biger table (i is primary key column)
    b -smaller table (m is primary key column)

    Code:
    insert into b select * from a where not exists (select * from b where b.m=a.i);
    Is it ok?

    Comment

    • jas2803
      New Member
      • Oct 2007
      • 30

      #3
      Thanks

      That was just what I needed, thanks very much!!!!!

      Comment

      Working...