Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 If error occurs in DTS

Author  Topic 

CRodwell
Starting Member

2 Posts

Posted - 2004-07-21 : 06:14:29
Hey There

I have created a DTS Package that gets executed from VB. It takes a text file with + - 800 000 Records and dumps it into a table.

Now my question is if one of my rows has incorrect data in it... Usually SQL will throw an error.... but I want to take that specific row and insert it into another table for instance "ERROR_TABLE".

Any Ideas of how to do this?

Regards
CRodwell

cas_o
Posting Yak Master

154 Posts

Posted - 2004-07-21 : 07:57:35
I am assuming you want to quarantine the bad record into a error_table, but continue processing the rest?

If the file is fixed width you could dts every column in the text file into a single varchar or char column in a staging table, then you can use substring to identify and insert to an error table, then import the good data to your final table.

Otherwise dts into your multi column staging table but have all columns as varchar, move dodgy records to your error table and insert the rest to final table.

Works for me.

;-]... Quack Waddle
Go to Top of Page

CRodwell
Starting Member

2 Posts

Posted - 2004-07-21 : 08:08:53
Thanks for the reply...

I have thought of this one but if I DTS everything into a staging table with columns as varchar... how will I programmatically identify that one of those columns has incorrect data?

IE: The field in question is supposed to be an integer but my DTS field has a varchar character in it... How do I identify the rows with dodgy data?

Thanks for the help again!
Go to Top of Page

cas_o
Posting Yak Master

154 Posts

Posted - 2004-07-21 : 10:30:44
select IsNumeric('1234'),IsNumeric('123A4')


;-]... Quack Waddle
Go to Top of Page
   

- Advertisement -