View Full Version : delete the excel data before insert new data


accessman2
12-30-2005, 11:46 AM
Question:

I created the package and execute the package which is transfer data from SQL Server table to Excel file
but, if I execute it for 2 times, the values will be output double in the same Excel table,

eg.
1st execute:
Name:
Jim
Mary

2nd execute:
Name:
Jim
Mary
Jim
Mary

I want to execute the package which values will replace the previous file's values if the filename is same.

How to delete/clean up the data of the Excel file, and then insert the new data?

Thanks.

Rickster57
12-31-2005, 07:40 AM
Not sure if this is what you had in mind. If you want to delete all the data before transferring the data then run the following code in a macro in the excel spread sheet.

Sub Macro1()
'
'
Dim r As Long
For r = 1 To 10000 ' or how many rows you want to delete
Rows(r).EntireRow.Delete
Next r

'
End Sub