SSIS - not truncate if it fails

105 Views Asked by At

Currently I have an Excel file that I load into a table every night. To do this, I make a TRUNCATE of the table and then I have a data flow in which I load the data from the Excel file to my table.

In the case the loading fails, I would like not TRUNCATE. Is it correct to make a rollback?

thank you.

3

There are 3 best solutions below

0
On

You should see how transactions are handled in SSIS. For more details please read below

http://msdn.microsoft.com/en-us/library/cc304421.aspx

2
On

TRUNCATE is an operation you can't simply rollback. I suggest you other method:

  1. Load data to temporary table.
  2. If everything was fine rename temporary table to your table name and voila.
  3. In case there was a failure you'll still have an image of your original table.
0
On

You could use transactions with for example TSQL: enter image description here