dbTalk Databases Forums  

How do I add three columns and data to a csv?

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


Discuss How do I add three columns and data to a csv? in the microsoft.public.sqlserver.dts forum.



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

Default How do I add three columns and data to a csv? - 07-01-2003 , 01:15 PM






Hi,

I'm trying to use DTS to solve the following mess:

1) I have 120 excel spreadsheets/day
2) I run 120 macros on these excel spreadsheets
- the macro does the following:
1) Inserts three columns
2) Enters in data: server, date, time. These are all the same
for a given spreadsheet.
3) Then I use BCP to import into SQL tables.

I was shown DTS. And it looks great. Except I cannot figure how to do
some preprocessingon my csv. I'd love to have something add three
columns, insert the data. Could this be done like my excel macros?
Prompt for the server, date, time for each file, then away it goes? It
would save me hours.

Thanks in advance!

Reply With Quote
  #2  
Old   
Edgardo Valdez
 
Posts: n/a

Default How do I add three columns and data to a csv? - 07-01-2003 , 01:47 PM






I would load the files using DTS and then add the columns
usin the data recently loaded. For instance:

1-. Load the file to a table call temp
2-. Populate the destination table with:

insert into destination table
select *, [server], [date], [time]
from temp


Quote:
-----Original Message-----
Hi,

I'm trying to use DTS to solve the following mess:

1) I have 120 excel spreadsheets/day
2) I run 120 macros on these excel spreadsheets
- the macro does the following:
1) Inserts three columns
2) Enters in data: server, date, time. These are
all the same
for a given spreadsheet.
3) Then I use BCP to import into SQL tables.

I was shown DTS. And it looks great. Except I cannot
figure how to do
some preprocessingon my csv. I'd love to have something
add three
columns, insert the data. Could this be done like my
excel macros?
Prompt for the server, date, time for each file, then
away it goes? It
would save me hours.

Thanks in advance!
.


Reply With Quote
  #3  
Old   
Edgardo Valdez
 
Posts: n/a

Default Re: How do I add three columns and data to a csv? - 07-01-2003 , 04:58 PM



Well, unless I misunderstood the original situation, some
macros are adding the 3 extra columns and BCP is
performing the upload to the final table.

My suggestion was aiming to use DTS for the load and add
the columns without using the macros. A truncate log task
can be added as a part of the DTS, if increasing of the
log is an issue.

Quote:
-----Original Message-----
In article <085b01c34001$423c2a10$a101280a (AT) phx (DOT) gbl>,
Edgardo Valdez
edgardovaldez (AT) hotmail (DOT) com> writes
I would load the files using DTS and then add the columns
usin the data recently loaded. For instance:

1-. Load the file to a table call temp
2-. Populate the destination table with:

insert into destination table
select *, [server], [date], [time]
from temp


In this case I don't see the staging table really adds
anything, apart
from a larger log.

Import the file straight into the final table with the
three extra
columns. You could easily add an ActiveX Script Transform
that reads the
three values from global variables. I would populate the
global
variables in advance using an ActiveX Script Task where
you can easily
derive the date, time and even the server name via the
scripting object.
ActX may be slower than copy column but then at least it
is a single
stage process, but testing is the only way to really
prove this.


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


.


Reply With Quote
  #4  
Old   
Neal Myerson
 
Posts: n/a

Default Re: How do I add three columns and data to a csv? - 07-02-2003 , 02:18 PM



Thanks, I did this and it works great.

Wow, this is cool stuff. If you don't mind one more question...

Is there any easy way to have an ActiveX script populate the text file
that is transformed? It doesn't seem to let me use a global variable,
as it wants to parse the file immediately or at least check that it
can.

Ideally, I'd love the ActiveX script to fire and prompt: What file?
I'd then enter a file, it would then figure out the server name and
time from the file name and away it would go.

Thanks again!

Reply With Quote
  #5  
Old   
Neal Myerson
 
Posts: n/a

Default Re: How do I add three columns and data to a csv? - 07-02-2003 , 02:50 PM



Ok, I posted a follow up that I got this working. And now I can
dynamically change the file name. Very fun.

Now the icing on the cake would be:

Scroll through this directory and for every file named X, run this
package.

I'm going to do a little research, it shouldn't be too hard, right?

Thanks everyone!

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

Default Re: How do I add three columns and data to a csv? - 07-02-2003 , 03:35 PM



In article <9488fec2.0307021150.6809f788 (AT) posting (DOT) google.com>, Neal
Myerson <nmyerson (AT) hotmail (DOT) com> writes
Quote:
Ok, I posted a follow up that I got this working. And now I can
dynamically change the file name. Very fun.

Now the icing on the cake would be:

Scroll through this directory and for every file named X, run this
package.

I'm going to do a little research, it shouldn't be too hard, right?

Thanks everyone!
Perhaps this article may help. You can use the file system object to
enumerate files and drive loop of this-

Looping, Importing and Archiving
http://www.sqldts.com/default.aspx?6,103,246,0,1
--
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.