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!

Logging missed insert records 1

Status
Not open for further replies.

sogc

Technical User
Jun 8, 2004
34
CA

Background
I have created a simple DTS Package to insert records into a table. Upon inserting the records from a tab delimited file I am picking up another field from an existing table via a join I created in the DTS Execute SQL Task object that is performing my insert.

Using SQL 2000

Problem
I have records in my tab delimited file for which there is no matching record in the joined table. The result is that the DTS Package executes with no errors and only insert records that can find a match in the joined table. However, I get no error log input indicating the records from the tab delimited file that did not get inserted.

Question
How can I log records that do not get inserted?
 
As you said, the records from your input file are being eliminated by the INNER JOIN you are using for the INSERT. If you just want to know which records from the input file didn't get inserted, you will need another task to INSERT those records into another table. Something like this will produce the rows from the input file that do not have a corresponding row in the join table. Good luck!

Code:
INSERT InputErrors
SELECT i.*
FROM InputTable i
   LEFT OUTER JOIN JoinTable j
       ON i.key = j.key
WHERE j.key IS NULL

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top