How to add variables to a table in SSIS

  • Hi all, I'm in need to import several flat files into a SQL table. I'm used to importing one at a time, but I'm new and starting to figure out SSIS. I do need to update a field in the destination table with the filedate (which is not always the current date or in any consistent format). So I was wondering if there are any methods to input this date variable in SSIS.

  • aliens218 (4/16/2013)


    Hi all, I'm in need to import several flat files into a SQL table. I'm used to importing one at a time, but I'm new and starting to figure out SSIS. I do need to update a field in the destination table with the filedate (which is not always the current date or in any consistent format). So I was wondering if there are any methods to input this date variable in SSIS.

    Not easily. Your best bet is to set it as a parameter when you call it for a particular file, then launch it using command line for SSIS packages. It's pretty much the only way you want to approach this.

    You CAN get yourself msgboxes and the like via scripts, but they break the job if you ever run it outside of BIDS/VS, because it just hangs waiting for an answer.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Im not totally sure what you're doing with SSIS but if the intention is to loop through a list of files and import its data into a table, this is how I'd do it:

    In the control flow use a For each loop container to loop through the files, set each filename to a global variable

    Inside the For each loop container use a Data Flow Task

    Inside the Data Flow task Use a Flat File Source using the filename stored in the variable

    Connect the Flat file source to a script component which would read the file date and set the date to an extra output from the script component

    Connect the Script component output to the preferred Destination component (ADO/OLE Db etc..) and store the data, including the new data field

    .................................................................................................................................................................

    Linkedin profile[/url]

  • Thanks for the responses. I had heard about the ForEachLoop... not very familiar with it, but plan on reading up on it. Wish it had an easier solution.

  • Another thought: If I put these variables (Filedate, filename) in a separate lookup table, can I get SSIS Data flow task to pull this information from the lookup table? How would I go about doing that?

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

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