Hey,
1)
I'm doing a lot of importing (by DTS packages) from commaseparated files
into tables where i empty/truncate the table _before_ import of ALL info in
the file.
BUT - how do I import data from such a file by an UPDATE command...
Meaning if the table has an ID col and a NAME col, and the file has an ID
col and a NAME col - then I would like to be able to UPDATE all NAME-cols in
the table by using the info from the file. The NAME in the file might have
changed, but the ID stays the same... Also, i new ID's are in the file, they
should be INSERTed into the table (+ the NAME).
2)
I have been using ActiveX Data Trans for some imports - but it would be
great if I could perform SQL-taks (like above perhaps...? or is the
another way) - meaning: how do I make SQL call from within an ActiveX task?
Any help appreciated - Thanx!
Best regards
Jakob H. Heidelberg
Denmark> BUT - how do I import data from such a file by an UPDATE command...
> Meaning if the table has an ID col and a NAME col, and the file has an ID
> col and a NAME col - then I would like to be able to UPDATE all NAME-cols
in
> the table by using the info from the file. The NAME in the file might have
> changed, but the ID stays the same... Also, i new ID's are in the file,
they
> should be INSERTed into the table (+ the NAME).
We do this every morning, or more accurately we have a scheduled task that
does this every morning. These are the general steps we use:
Select everything from the CSV file into a temporary table.
Update the rows that need updating in the target from the temp table, then
delete the source rows. You can do updates using joined tables, or create a
cursor and do them one record at a time.
Insert whatever's left in the temp table
Destroy the temp table.
Can't really help you with your other question; I could guess, but I'd
likely be wrong and sound more an idiot than normal. I leave that to the
rest of our colleagues.
William Morris
Product Development, Seritas LLC
Kansas City, Missouri|||Thanx.
can you tell me how to create the TEMP table, and how to INSERT into it?
Also, when will the table "die"?
Thanx in advance
Jakob
""Sokrates"" <somebody@.somewhere.earth> skrev i en meddelelse
news:c29sc1$1rlv$1@.news.cybercity.dk...
> Hey,
> 1)
> I'm doing a lot of importing (by DTS packages) from commaseparated files
> into tables where i empty/truncate the table _before_ import of ALL info
in
> the file.
> BUT - how do I import data from such a file by an UPDATE command...
> Meaning if the table has an ID col and a NAME col, and the file has an ID
> col and a NAME col - then I would like to be able to UPDATE all NAME-cols
in
> the table by using the info from the file. The NAME in the file might have
> changed, but the ID stays the same... Also, i new ID's are in the file,
they
> should be INSERTed into the table (+ the NAME).
> 2)
> I have been using ActiveX Data Trans for some imports - but it would be
> great if I could perform SQL-taks (like above perhaps...? or is the
> another way) - meaning: how do I make SQL call from within an ActiveX
task?
>
> Any help appreciated - Thanx!
> Best regards
> Jakob H. Heidelberg
> Denmark
>
>
>
Friday, February 24, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment