How to skip the last line in an SSIS data stream

I use FlatFile Source ManagerScript COmponent as TransOLEDB destinationin my data stream.

The source reads all the lines from a flat file, and I want to skip the last line (trailer entry) updating the database.

Since it contains values NULL, the database raises an error.

Help me how to solve this.

Regards, VHK

+4
source share
2 answers

If you need to avoid lines having null values ​​in a flat file, you can follow below,

  • Reading data from a flat file using the source component.
  • Conditional Split , case expression !ISNULL(Column1) && !ISNULL(Column2) (Column1 Column2 . , ID , !ISNULL(ID)).
  • OLEDB.

, .

+1

, :

  • DataFlow Task ( DFT RowCount)
  • System.Int32 (: :: RowCount)
  • DataFlow Flat File Source (, )
  • RowCount Flat File Source
  • RowCount User::RowCount

enter image description here

  1. DataFlow Task ( DFT Import)

enter image description here

  1. DFT Import Flat File Source (, )
  2. Script Component Flat File Source
  3. User::RowCount Script ReadOnly

enter image description here

  1. DT_BOOL (: IsLastRow)

enter image description here

  1. Script Script

    Dim intRowCount As Integer = 0
    Dim intCurrentRow As Integer = 0
    Public Overrides Sub PreExecute()
        MyBase.PreExecute()
        intRowCount = Variables.RowCount
    End Sub
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        intCurrentRow += 1
    
        If intCurrentRow = intRowCount Then
            Row.IsLastRow = True
        Else
            Row.IsLastRow = False
        End If
    
    End Sub
    
  2. Conditional Split Script

  3. ,

    [IsLastRow] == False
    

enter image description here

  1. OLEDB Destination

enter image description here

: ( ), Script writen Script,

+2

Source: https://habr.com/ru/post/1671669/


All Articles