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)
 Text file to SQL db; wanting to drop records

Author  Topic 

megrenk
Starting Member

2 Posts

Posted - 2004-07-07 : 06:52:27
Hi There,

I am new to SQL -- that's a worry in itself :)

I have manged to selfteach and setup some packages that import tab-delimited text fiels into a table that gets truncated every time prior to import. Then a sp kicks in to move the temp tbl fields to the real table.

I have found that some records contain stuff which wants me to drop the whole record.

In this case I am importing product, price, quantity information, where some products have either no price or no quantity, or a quantity with "N/A" (chars in it).

What is the best way to drop these record, so they wan't be imported into the temp tbl? Would I have to write VB in an ActiveX component??

The temp tbls have all fields as varchar, which I convert during the insert into the real tbl.

Any help would be much appreciated.

Thanks and regards,
Max

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-07-07 : 19:42:35
Max,

Easiest way would be to use the temp table like you've indicated, but let the whole file import into it (warts and all). You can then filter the records for import into your production tables.

Tim

btw - Got your email at work this morning. Will respond from my personal account tonight.
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2004-07-07 : 19:49:15
You can also use dts/or etl tool filter out the records in the transformation.
Go to Top of Page

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-07-07 : 20:52:29
You can also use T-SQL to load data from a text file using regular WHERE clause using the text driver. You should be able to load data from the text file directly into your permanent table.
Here is an example:
http://users.drew.edu/skass/sql/TextDriver.htm
Go to Top of Page

megrenk
Starting Member

2 Posts

Posted - 2004-07-08 : 03:21:10
Thanks guys!

kselvia's link was an interesting read, in regard to what can be done.

I will get righ into it... :) and bug you most likey with more questions.

Cheers,
Max
Go to Top of Page
   

- Advertisement -