Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 How to run DTS package AND delete rows in table

Author  Topic 

bardun
Starting Member

2 Posts

Posted - 2004-07-14 : 12:05:42
Ok.
I am not very good with anything regarding dbs, but I am learning as I go. What I am doing is the following:
1: Filling out form on pda, uploading to a table with 3 primary keys. No problem there. Created table, uploaded form, downloaded values.
2: I want to transfer the data in this table (which is a transfer table for my purposes) to other tables where they will permanently reside.
3: I would like to use DTS for that, since it is easy to use.
4: The following is what I like to be able to do by running a batch file:
a: copy all values/fields from transfer table to real tables by executing a DTS package(s). I know how to create DTS packages.
b: delete all rows in the transfer table (so there are no value left) after the transfer has been completed.
c: If there is an error during the transfer, I do not want the data in the transfer table to be deleted (since obviously it is not put anywhere).

The reason I need to delete the value in the transfer table after they are transfered to the other tables is because there are three primary keys, and if I run the DTS package with the same data I get duplication error of pk's.

Is this possible? If it is, can someone please point me in the right direction?

Thank you so much for any help!

Bardun

--------------------
I usually need help!

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-07-14 : 19:12:16

A simple way to do this would be to add an Execute SQL task in your package, and set it to run only if the preceeding step is successful. This can be done using the workflows in DTS.

Go to Top of Page

bardun
Starting Member

2 Posts

Posted - 2004-07-14 : 21:34:48
Yeah, I tried doing that, but could not get it to work right. I know waaay to little of code and everything, and I just started that stuff today. Anyway, I also see that some of my fields, time and a date field, are not importing correctly (date and time are messed up).

I have looked at other ways of doing it, but really drawing a blank as my knowledge is severely lacking in this sense.

I will keep researching though, and try to come up with something that will work.

Thanks, and if you have any other thoughts, please let me know.

Bardun

--------------------
I usually need help!
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-08-10 : 07:27:04
You should design your own DTS package instead of using the wizard. The Design will allow you to define what you just described. If Step1 fails then step2 will not proceed.

step 1: copy data from source to target
step 2: delete data from source

between step1 and step2 use a workflow and define that only after completing step1 successfully, step2 follows.
Go to Top of Page

mpex04
Starting Member

1 Post

Posted - 2004-08-11 : 13:54:01
I would suggest creating a Execute SQL Task writing a truncate table statement. Have that as your first step so that whenever the package runs, it will truncate the table first before inserting new records.
Go to Top of Page
   

- Advertisement -