dbTalk Databases Forums  

Validation prior to inserting data

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Validation prior to inserting data in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John
 
Posts: n/a

Default Validation prior to inserting data - 04-13-2004 , 09:35 PM






I created a DTS package that downloads a text file from an ftp site,
deletes the existing data in the sql table, and then inserts the new
data from the text file. The package works but I have run into
instances where the source text file has invalid data - duplicate
primary keys. When this happens the data doesn't get loaded and I end
up with an empty table.

My question is what checks can I put in place (and how can this be
done) so I am not left with an empty table? If an error like this
were to occur, I would like to know as well.

Thanks.

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Validation prior to inserting data - 04-14-2004 , 12:56 AM






Personally I validate a text file by importing it into a working table and
then running TSQL over the top. So you duplicate PK would be easy
Either you set a PK on the working table or you do something like

SELECT PK_COL, COUNT(*)
FROM TABLE
GROUP BY PK_COL
HAVING COUNT(*) > 1


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"John" <jrp210 (AT) yahoo (DOT) com> wrote

Quote:
I created a DTS package that downloads a text file from an ftp site,
deletes the existing data in the sql table, and then inserts the new
data from the text file. The package works but I have run into
instances where the source text file has invalid data - duplicate
primary keys. When this happens the data doesn't get loaded and I end
up with an empty table.

My question is what checks can I put in place (and how can this be
done) so I am not left with an empty table? If an error like this
were to occur, I would like to know as well.

Thanks.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.