delete the excel data before insert new data (1 Viewer)

accessman2

Registered User.
Local time
Today, 07:06
Joined
Sep 15, 2005
Messages
335
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

Registered User.
Local time
Today, 07:06
Joined
Nov 7, 2005
Messages
431
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
 

Users who are viewing this thread

Top Bottom