[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

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?
0
DSchat
Asked:
DSchat
  • 8
  • 5
  • 4
2 Solutions
 
Jay ToopsCommented:
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
0
 
DSchatAuthor Commented:
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.
0
 
Jay ToopsCommented:
there is no setting in the data pump to append
however you could write an active X task to create the file
and use a filesystem object and append to that.
of course that means you would have to write the code to output
your file manually.


Personally id take the create table option Above.

Jay
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
arbertCommented:
"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?
0
 
DSchatAuthor Commented:
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?
0
 
DSchatAuthor Commented:
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?
0
 
arbertCommented:
" 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...
0
 
DSchatAuthor Commented:
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?
0
 
arbertCommented:
Yes, that's the only place....The data in the table will NOT be truncated automatically.  Unless you have an explicit delete or truncate in your DTS job, the data will automatically append to the table (as long as you don't have primary key constraint violations of course).

What else does the package do?
0
 
DSchatAuthor Commented:
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.
0
 
arbertCommented:
"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.
0
 
Jay ToopsCommented:
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
0
 
DSchatAuthor Commented:
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
0
 
DSchatAuthor Commented:
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.
0
 
Jay ToopsCommented:
I disagree
0
 
Jay ToopsCommented:
split Jltoops and Arbert

Jay
0
 
DSchatAuthor Commented:
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
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 8
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now