Set package variable based on flat file date field

  • I'm relatively new to SSIS. I am trying to figure out how to set a package variable "DateExtracted" using a field in my flat file.

    In my data flow I have a flat file source, a sort, a conditional split, and a raw file destination. All of this is working fine. I just need to set the value of my package variable "DateExtracted". Can someone suggest a way to do this, which component to use and where.

    Thank you,

  • Add a script component (of data flow task) between Source & Target components.

    The VB.NET Code should be something like:

    Imports System

    Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

    Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

    Public Class ScriptMain

    Inherits UserComponent

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

    Dim varsVariables As Variables

    Dts.VariableDispenser.LockOneForWrite("DateExtracted", varsVariables)

    varsVariables(0).Value = Row.DateExtracted

    varsVariables.Unlock()

    End Sub

    --Ramesh


  • Ramesh,

    I'm trying this, but getting an error that Dts "Name is not declared". I must be missing something here. Here is my code.

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

    Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

    Public Class ScriptMain

    Inherits UserComponent

    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

    '

    ' Add your code here

    '

    Dim varsVariables As Variables

    Dts.VariableDispenser.LockOneForWrite("varDateExtr", varsVariables)

    varsVariables(0).Value = Row.DateExtracted

    varsVariables.Unlock()

    End Sub

    End Class

    I apologize if this is a stupid question. Thanks for your help!!!

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

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