dbTalk Databases Forums  

How to import a txt file with dynamic column names using DTS?

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


Discuss How to import a txt file with dynamic column names using DTS? in the microsoft.public.sqlserver.dts forum.



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

Default How to import a txt file with dynamic column names using DTS? - 08-06-2003 , 11:24 AM






I wanna to use DTS to import a fixed named txt file
which contains some fields with the dynamic date names
for the inventory forecast ,e.g.
20030801;20030802;20030803 ,and next day the fileds name
will bacame : 20030802;20030803;20030804.
I create one DTS package to import this txt file and
map to a destination table (drop then create). But once I
update the txt file with new date column name , the
maping appears wrong and the package execute result
failure.
Is there any better way to solve this probelm?


Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: How to import a txt file with dynamic column names using DTS? - 08-06-2003 , 01:48 PM






In article <0d4201c35c37$33412590$a601280a (AT) phx (DOT) gbl>, louyueming
<louym (AT) citiz (DOT) net> writes
Quote:
I wanna to use DTS to import a fixed named txt file
which contains some fields with the dynamic date names
for the inventory forecast ,e.g.
20030801;20030802;20030803 ,and next day the fileds name
will bacame : 20030802;20030803;20030804.
I create one DTS package to import this txt file and
map to a destination table (drop then create). But once I
update the txt file with new date column name , the
maping appears wrong and the package execute result
failure.
Is there any better way to solve this probelm?

Are these field names in the source file? If so and they go into
standard named columns you could just skip the first row.

If you want the field name in the source file to determine the column in
the destination it will be more difficult. You could do something that
dynamically changed the transformations in the data pump, but this is
quite hard work.

I would just load it into a simple table and then use dynamic SQL to
pump it into the final table. This way all the dynamic work is just in
one SQL batch and shouldn't be too hard to manage compared to a full DTS
alternative.

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com




Reply With Quote
  #3  
Old   
Lou Kenny
 
Posts: n/a

Default Re: How to import a txt file with dynamic column names using DTS? - 08-07-2003 , 01:25 AM





Then ,what dynamic sql can I use for importing a txt file to a SQL table
? Does command bcp match my requirement to pump the sour data with
alternable fields name into a sql table ?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: How to import a txt file with dynamic column names using DTS? - 08-07-2003 , 11:30 AM



In article <ODk3AzKXDHA.3232 (AT) tk2msftngp13 (DOT) phx.gbl>, Lou Kenny
<louym (AT) citiz (DOT) net> writes
Quote:

Then ,what dynamic sql can I use for importing a txt file to a SQL table
? Does command bcp match my requirement to pump the sour data with
alternable fields name into a sql table ?

You cannot use dynamic SQL to load a text file into a table. You can use
SQL to move data betwen two tables, and if the destination columns keep
changing then you could build this statement dynamically to derive the
column names. Column names may not even be required if your INSERT ...
SELECT statement supplies all values.

BCP or Bulk Insert may be a better option since they do not require
always column information.

I cannot be more specific as I still don't understand exactly what you
are trying to do.

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com




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.