By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Insert records

P: 30
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?
Jan 27 '09 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 700
a- biger table (i is primary key column)
b -smaller table (m is primary key column)

Expand|Select|Wrap|Line Numbers
  1. insert into b select * from a where not exists (select * from b where b.m=a.i);
Is it ok?
Jan 28 '09 #2

P: 30
That was just what I needed, thanks very much!!!!!
Jan 28 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.