Link to home
Start Free TrialLog in
Avatar of DSchat
DSchat

asked on

How do I get my Export DTS Job to append data, not overwrite it?

I've got a DTS Job that locks a table (hopefully) and exports all the data with the status 'X'. It then updates the status to 'Y'. I need to have the job run once an hour, in order to export the new data that came in. When the job runs it overwrite the data that I've already exported. Where is the parameter I need to set, to tell DTS to append the data?
Avatar of Jay Toops
Jay Toops
Flag of United States of America image

a) Export how?
b) if you are using a select into to place it in a new table
    change the code to insert into. this will append the data to that table

if you are creating an extract file then do this

create a table call it Daily Updates
then insert your selections into it each time
then create your extract file from the "daily update" table

Jay
Avatar of DSchat
DSchat

ASKER

I'm exporting right now into a text file. The option of first exporting in a table and then just once a day exporting that data to my file text was an option that I was also considering. I was wanting to see if I could change a setting inside SQL to get it to append.
ASKER CERTIFIED SOLUTION
Avatar of Jay Toops
Jay Toops
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"there is no setting in the data pump to append "

The datapump WOULD append unless your job also has a truncate or delete statement in it somewhere....

What if you get the same data again for some reason?  How do you want to handle that?
Avatar of DSchat

ASKER

I can't get the same data again, because after I exported I update my 'Status' column from X to Y. I only want the data with the value Y.

What I did was use the DTS Import/Export Wizard, pick out from Server.DB.table I wanted to export (with a select), I chose my type and place of my destination (a text file on another server). I saw a button that I could mark to append data, but it was greyed out. My only choice there was to create a table. Why does thta come when I just export to a text file?
Avatar of DSchat

ASKER

I think I might have found a way to append, but I don't know how I implement it. I need to set the AppendIfFileExists Property. I think it works with:

Set transprops = transform.TransformServerProperties
transprops"AppendIfFileExists") [= boolean]

Where and how do I put this SET Command in?
" My only choice there was to create a table. Why does thta come when I just export to a text file?"

Because you're using the wizard...If you edit the package after you create it with the wizard, you can get rid of any CREATE/TRUNCATE table statements and by default it WILL append the data...
Avatar of DSchat

ASKER

Do you mean in "design package"? I looked in there and I found nothing with CREATE/TRUNCATE. Is there any other place where you can edit a package? Is the package stored in a database or as a flat flie somewhere?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DSchat

ASKER

I've looked through all the different places (properties) where you can set the different parameter and there is nothing where I could set append. Also I could not find any place where a TRUNCATE is specifically refered to. I believe that the truncate is implicitly started.

I've tried it without using the wizard also. I've created an OLE DB connection and the object that I am exporting to is a text file. The export is done with a transform data task which has a simple SQL in the background, which defines what is to be exported.

It made no difference, the data was overwritten each time.
"I believe that the truncate is implicitly started."

Not in DTS...Text Files and Tables are different stories....

IF YOU HAVE A DTS JOB WITHOUT ANY DELETE OR TRUNCATE STATEMENTS, IT WILL APPEND TO THE TABLE.
There comes a point when u stop beating your head against a wall and just do it
this way:

create a table call it Daily Updates
then insert your selections into it each time
then create your extract file from the "daily update" table

Jay
Avatar of DSchat

ASKER

Thanks Jay, but your suggestion brings us back to the point we were at, when I started this question. My problem is that the table is exported once a day and if for some reason the exported data isn't tranported to the host on one day because of an error on that side or if is weekend (when the host isn't there) the export is triggered at it's scheduled time and it overwrites the text file that hasn't been picked up yet and my data is gone!

To arbert's comment: "Text Files and Tables are different stories...." how so? I just tested this myself, exporting into a table and saw that here the data is appended. So this is my difference between tables and text files. I used the same SQL to select which data to export. Everything is the same except the goal. This time a table instead of a text file.

But now my question is coming back around to the beginning, is there a way to append onto an exported text file? I need to do this for the reasons stated above.

Thanks for the help,
Doug
Avatar of DSchat

ASKER

I think I now have the solution myself. I will do the export to a text file and upon success I will start a *.bat/cmd file that copies the file to another location and when it already exists it will be appended.
I disagree
split Jltoops and Arbert

Jay
Avatar of DSchat

ASKER

Jay, you and Arbert gave me some good tips but it came out that DTS just overwrites a text file when you export to it again. I then figured out that I could use an Execute Process Task to copy the file to another location without overwriting. I believe this is more or less what you were suggesting in your comment with an activeX script. In the end I just did it with a CMD file with the command: "type filename1 >> filename2" It is still all controlled with DTS which is what I wanted.
So because of what both of you said, I will split the points, the tips from you guys will be useful to me. Do we have things settled now?

Doug