Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to add variables to a table in SSIS Expand / Collapse
Author
Message
Posted Tuesday, April 16, 2013 2:56 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 18, 2013 10:22 AM
Points: 4, Visits: 19
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.
Post #1443017
Posted Tuesday, April 16, 2013 3:17 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 6:08 PM
Points: 5,401, Visits: 7,514
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 | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
Post #1443025
Posted Wednesday, April 17, 2013 6:27 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 9:04 AM
Points: 1, Visits: 110
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
Post #1443220
Posted Wednesday, April 17, 2013 2:16 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 18, 2013 10:22 AM
Points: 4, Visits: 19
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.
Post #1443485
Posted Thursday, April 18, 2013 6:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 18, 2013 10:22 AM
Points: 4, Visits: 19
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?
Post #1443811
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse