Solved

How can I rename a dynamic source file in SSIS

Posted on 2011-03-02
6
385 Views
Last Modified: 2012-05-11
I have a CSV file XXXX_YYYYMMDD.CSV that I grab off of an FTP Site.  I am looking to rename this file after I place in my directory.  I am looking to rename the file to XXXX.CSV.  I try to rename it using the file system task however, the file will change everyday so I do not have the proper name once it is in my directory to change it.  Can anyone direct me in being able to change this dynamic file name?
0
Comment
Question by:AnthonyN917
  • 3
  • 3
6 Comments
 
LVL 22

Expert Comment

by:8080_Diver
ID: 35029973
The first thing you need to do is to create a couple of variables (let's call them SourceFileName and TargetFileName), then you set up your flat file source connectionmanager so that it uses the SourceFileName variable to determine what the file name is and the destination connectionmanager so that it uses the TargetFileName variable to determine where the destination file is to be written.  Because these are variables, you can use a Script Task to modify the values in those variables however you need to.  Then, when the action starts, the data will be fetched from wherever the SourceFileName varaiable indicates and it will be written to wherever the TargetFileName indicates.  

Note: If you're TargetFileName variable indicates a folder path that doesn't exist, you will need to make sure that you create the path portion of that filename prior to attempting to write to it.  That, too, can be done in a Script Task (e.g. the same place that the value is set).
0
 

Author Comment

by:AnthonyN917
ID: 35061840
Hello,

I appreciate the response, but I am just not sure how to write the script that will include the name in the SourceFileName variable.  I never really worked with scripts in SSIS before.
0
 
LVL 22

Expert Comment

by:8080_Diver
ID: 35061949
The code in a Script Task is VB.Net or C#.  If you can rite a script in VB.Net or C# to handle the name manipulation, then all you need to do is create the variable and reference it in the code using Dts.Variable("variablename").Value = {your code to create the filename}

Do some research on MSDN to learn about the Script Task object.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Accepted Solution

by:
AnthonyN917 earned 0 total points
ID: 35131126
Thanks, I did the research, it turns out that I did not need VB or C# Script.  The VS 2008 looping containers did all the work for me.
0
 
LVL 22

Expert Comment

by:8080_Diver
ID: 35131360
The VS 2008 looping containers did all the work for me.

Did that involve a variable of any sort?  Did you, perhaps, follow my advise to go to the MSDN site to do some research?
0
 

Author Closing Comment

by:AnthonyN917
ID: 35170972
I was able to figure it out myself.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Event ID 10010 3 36
Problem to Date and time Picker 32 95
wordpress limitations 4 91
What .NET website keeps me current? 9 29
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now