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)
 DTS- ActiveX Script - Import flat file

Author  Topic 

anthonyboud@yahoo.com
Starting Member

1 Post

Posted - 2005-03-27 : 05:20:23
I have a fixed length text file that I wish to import into SQL tables.

The text file will contain 2 different types of records. Firstly, a
header record, which is immediately followed by X number of detail
records.

Each record is 80 characters long, separated by a CRLF, and the type
of record is identified at the beginning (first 2 char's).

I would like to insert the header records into a header table,
returning the unique ID (auto incrementing ID) of the row inserted
into the header table, which will be used when inserting the
associated detail records.

Does anybody have any sample ActiveX scripts that do something similar
to the above?

Basically, I'm after an example script that opens a file, loops around
each row in the file and tests the data in some means.

Any examples would be absolutely fantastic and much appreciated!

Many thanks

Anthony

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2005-04-05 : 08:02:35
If your source file is of any significant size, it would be much quicker to bulk insert the whole lot into a staging table first and then process it within sql server.

Mark
Go to Top of Page

bclick
Starting Member

3 Posts

Posted - 2005-04-06 : 13:39:26
I have a similar task, but a bit more involved. No header line. I need to import my 9 million line (375 char max line len) text file into 6 different SQL tables, based on the first 2 chars.

And the six different text lines are not delimited, but field-length defined, parsed into different columns in each table.

ActiveX Case statement? Stored Procedure?

Thanks - Bil
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2005-04-07 : 16:26:05

Download a copy of gawk for windows and separate the file before loading.

http://gnuwin32.sourceforge.net/packages/gawk.htm
Go to Top of Page
   

- Advertisement -