Prevent flat file from being written (SSIS 2008r2)

  • SO In the project I'm working I'm importing csv files from a dynamic map to a database.

    As an extra feauture I made it so that all the lines that are faulty get written into a csv file and all the good lines into another.

    So that when correcting not all the lines have to be redone or people have to spend hours finding the correct line.

    So I originally did this in SSIS 2012 now I have to remake it in 2008r2,in 2012 if a flat file doesn't receive inputs it isn't written but it seems in 2008r2 it does.

    I can't go check the files based on size cause the column headers are already in the file.

    So I thought about using a rowcount into a variable and based on that execute a create script, I can create the file however only the last row is written and also how do I access the variables.

    The code section that should generate the lines is below & is based off

    http://agilebi.com/jwelch/2007/06/03/multi-file-output-destination-script-component/

    'This method is called once for every row that passes through the component from Input0.

    '

    'Example of reading a value from a column in the the row:

    ' zipCode = Row.ZipCode

    '

    'Example of writing a value to a column in the row:

    ' Row.ZipCode = zipCode

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

    Dim column As IDTSInputColumn100

    ' If Not Row.SERVER = previousValue Then

    If Not fileWriter Is Nothing Then

    fileWriter.Close()

    End If

    fileWriter = New StreamWriter(targetFolder + fileName + fileCount.ToString() + fileExt, False)

    'fileCount += 1

    'previousValue = Row.SERVER

    'End If

    With fileWriter

    .Write(Row.SERVER + delimiter)

    .Write(Row.STATUS.ToString() + delimiter)

    .Write(Row.OU.ToString() + delimiter)

    .Write(Row.OS.ToString + delimiter)

    .Write(Row.SP.ToString + delimiter)

    .Write(Row.VERSION.ToString() + delimiter)

    .Write(Row.INSERVEROU.ToString + delimiter)

    .Write(Row.DATEADDED.ToString + delimiter)

    .Write(Row.DATECHANGED.ToString() + delimiter)

    .WriteLine()

    End With

    If Not Row.SERVER = previousValue Then

    fileWriter.WriteLine()

    previousValue = Row.SERVER

    End If

    End Sub

  • Maybe you could come at this from another angle.

    Why not put a rowcount transformation underneath the script component and then delete the file in the control flow if [rowcountvariable] == 0?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Tried that and it still executed the flat file destination

  • Resender (2/20/2013)


    Tried that and it still executed the flat file destination

    I did not say it wouldn't.

    My suggestion is to perform the deletion as part of the control flow - after the completion of the data flow and after the file has been created.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply