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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automated insertion of records

Status
Not open for further replies.

futbwal15

IS-IT--Management
Jan 12, 2007
38
US
all i want to be able to do is automate the process of inserting brand new rows into my table. when the table is scanned, i need to know when a record is NOT in the table so it can then be inserted. if a record already exists, then that item is skipped....any ideas for coding?
 
One way:

Code:
insert into finalTable (col1, col2)
select col1, col2 from StageTable
where col1 not in (select col1 from finalTable)

This assumes that col1 is your primary key and is shared between the two tables.

Good luck

Alex

Ignorance of certain subjects is a great part of wisdom
 
It all depends upon how you know which records exist and which are missing? Are you comparing values from a different table? Are the records supposed to be sequential based upon a sequence field? ...

Triggers and SPs can be used to validate the integrity of the table as long as rules can be clearly defined.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top