all groups > sql server dts > august 2005 >
You're in the

sql server dts

group:

Upload Txt Files as Tables with Same name via Recursive DTS



Upload Txt Files as Tables with Same name via Recursive DTS Kevinoh
8/19/2005 11:28:02 AM
sql server dts: Hello,
I'm got a subdirectory containing a large number of flat files. I want to
use DTS to recursively import them into a database, using a DTS package that
iterates through the subdirectory, creating tables with the same names as the
files being imported. I'm using SQL 2000 on W2K machines. Can someone point
me to a good example of this? Thanks.
--
Re: Upload Txt Files as Tables with Same name via Recursive DTS Kevinoh
8/19/2005 1:21:03 PM
Yes, thanks Allan, your example .DTS would be very helpful.
--
Kevinoh


[quoted text, click to view]
Re: Upload Txt Files as Tables with Same name via Recursive DTS Allan Mitchell
8/19/2005 8:41:29 PM
There are no samples to do the whole solution but you can certainly do it.

You will need to loop over a directory

Looping, Importing and Archiving
(http://www.sqldts.com/default.aspx?246)


And then you will need to dynamicaly recreate your SourceObjectName,
destinationObjectName, the mappings etc

The second part here is not easy but I have a package which does something
not too dissimilar in that it recreates a datapump from scratch. Ping me if
you want it.




[quoted text, click to view]

Re: Upload Txt Files as Tables with Same name via Recursive DTS John
8/20/2005 5:56:07 PM
The easiest solution would be to use a couple of ActiveX script tasks and
FileSystemObject around your transform. You can iterate through the
directory, on each iteration taking the filename and assigning it to a
global variable and adjusting your textfile's .DataSource property to the
name of the textfile and so on. Similarly for the table name. Once you
have used a transform data task to import the file, use another activeX task
to delete the filename contained in the global variable. Repeat the loop
until there are no more files in the directory; at that point disable
remaining steps and exit package with success.

Hope this helps,
John Glass


[quoted text, click to view]

Re: Upload Txt Files as Tables with Same name via Recursive DTS Allan Mitchell
8/20/2005 11:21:16 PM
John

The original poster also wanted to create the tables as they went based on
the defintiion of the text file encountered. To have this automated means a
rebuild of the Data Pump task on each iteration as mentioned in my reply.
The looping around the files is relatively easy with this article.

Looping, Importing and Archiving
(http://www.sqldts.com/default.aspx?246)



[quoted text, click to view]

Re: Upload Txt Files as Tables with Same name via Recursive DTS Kevinoh
8/23/2005 6:31:10 PM
Thanks for your posts and suggestions. I was able to adapt the previosly
mentioned script, so that I create tables with the same names as the files as
I iterate through the directory. This has worked perfectly in one
subdirectory, and partly in another.

However, it is now failing due to the "Column deliminator not found" error
(Error Source: DTS Flat File Rowset Provider) on some files. Curiously, I
have been able to import these very same files using the DTS wizard, without
any problems.

I've checked these settings in the Data Pump task, and they haven't changed;
nor is there any difference in the files that I can see. Any advice as to how
to troubleshoot?
--
Kevinoh


[quoted text, click to view]
Re: Upload Txt Files as Tables with Same name via Recursive DTS Kevinoh
8/24/2005 10:00:03 AM
Just a note that I figured this out. My file format settings had somehow
changed ; once I changed them back under the File Connection Properties
button, it runs just fine. Thanks again.
--
Kevinoh


[quoted text, click to view]
AddThis Social Bookmark Button