Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can APPEND data into a table only if record does not exist. 1

Status
Not open for further replies.

jms493

MIS
May 16, 2007
11
US
I want to run a a query at any time and only inserts/appends data to the table if the record does not exist. No duplicate rows.

How can write this?
 
If you have a (real) primary key, you can use a left join.

Code:
insert into myTable
select a.* from myOtherTable a
left join myTable b
on a.PK_Value = b.PK_Value
where b.PK_Value is null

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Beautiful Dennis.....Stored procedure created and job created to run every month.

Thanks for the help guys. People will think I am actually smart today!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top