Results 1 to 4 of 4

Thread: SSIS Package

  1. #1
    Join Date
    May 2009
    Posts
    41

    SSIS Package

    Hi

    I am facing some problem while exporting the data from SQL to excel.

    My package first truncates the old data from the destination table and then picks up new data from source and puts it again to destination table(which was truncated). And then it inserts the data in an excel file.

    This package is scheduled to run everyday once at a particular time.

    But what happens is, In my excel file, the rows are adding up.

    Suppose the package exceuted today for the first time, the no. of rows in the excel file are 5.

    On the next day, there will be a new set of rows in my excel file but the rows from previous day are also there. i.e the new set of rows begin after the 5th row from previous day.and it continuous this way.

    What i want is to have only the fresh data in my excel file every day.

    I dont want to have the rows from the previous day in my excel file.

    I hope i made myself clear.

    Can you help me with this???

    Thanks!!!

  2. #2
    Join Date
    Oct 2009
    Posts
    6
    The easiest will be to create a script task that will delete your Excel file. Here is a sample script:

    Public Sub Main()

    Dim strSourceFile As String
    strSourceFile = Dts.Variables("User::varFileName").Value.ToString

    If File.Exists(strSourceFile) Then
    File.Delete(strSourceFile)
    End If

    Dts.TaskResult = Dts.Results.Success
    End Sub

  3. #3
    Join Date
    Jun 2004
    Location
    Atlanta and Manhattan
    Posts
    607

    Or to create a new one each day ...

    Perhaps using logic to name each by date, etc. (Only if you anticipate ever needing to get back to a given date's data, etc.)

    HTH,

    Bill

  4. #4
    Join Date
    Nov 2009
    Location
    Boston, MA
    Posts
    1

    Control Flow Task

    I can think of two options.

    1) In SSIS, on the Control Flow panel, you can use a File System Task to delete the excel file before you start processing it.

    2) You can also use the File System Task to rename the old file if you want to keep them around.

    Do these help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •