?
Solved

help with ssis package

Posted on 2013-06-20
4
Medium Priority
?
252 Views
Last Modified: 2016-02-11
Hi Experts,
I have a data source which loads data from a table and load into a flat file(.csv), and I have an ftp task that send this file onto an ftp server.
I need to make sure the flat file has date appended to the name of the file and I need to make the ftp pick that file . I guess we need to use variables for this.
Please suggest me how to go about and also I need to deploy this to a server, so I should be providing the configuration file?
0
Comment
Question by:sqlcurious
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:DcpKing
DcpKing earned 1000 total points
ID: 39264755
What you do is use a variable for the name, and compose it (for max. flexibility) like this:

1. create four variables: one each for the date string, the file name, the extension, and the resultant file spec. Make sure that they are all in the package namespace - that is, make sure that you're working in the Control Flow pane and that absolutely nothing is selected. Look at screengrab DateName_1 for an example

2. Set the extension and filename variables to whatever you need them to be. See DataName_2.

3. DateName_3 shows how the datestring is composed. You have to select the variable, go to its properties, set the EvaluateAsExpression property to True (double-click the word False), go to the Expression line below it,  and click on the little button with the ellipsis at the right hand end. Once there the code (in this case) is
(DT_WSTR, 4) year(getdate()) + 
right("0" + (DT_WSTR, 2) month(getdate()), 2) + 
right("0" + (DT_WSTR, 2) day(getdate()), 2)

Open in new window


4. Now do the same for the strFileSpec variable. The code this time is
@[User::strFileName] + "_" +  @[User::strDateString] +  @[User::strExt]

Open in new window

and you get the references to the other variables either by typing (if you're clever) or by dragging the variable down from the list in the dialog box. In DateName_4 I've done this and clicked on Evaluate Expression to show what the result is.

Once you've got this you can use it in a FileSystem task as the destination of a rename operation - let your normal export operation (in dataflow) always go to some constant name, and then rename the file to this after you're done writing to it.

Finally, you want to sent it to the FTP system. Well, you can again use the variable to supply the file name for the FTP task. Here I just concatenated filename, date, and extension, but you can add the path as well, of course!


hth

Mike
DateName-1.png
DateName-2.png
DateName-3.png
DateName-4.png
0
 
LVL 21

Accepted Solution

by:
Alpesh Patel earned 1000 total points
ID: 39267538
You can create dynamic file name using expression

"\\\\" +  @[User::FILE_SHARE] + TRIM(@[User::Done]) + LTRIM(@[User::FileName]) + (DT_WSTR,4)YEAR(GETDATE()) + RIGHT("0" + (DT_WSTR,2)MONTH(GETDATE()), 2) +  RIGHT("0" + (DT_WSTR,2)DAY( GETDATE()), 2) +   ".txt"


and using FTP task upload file to server using Sendfiles operation.
0
 

Author Comment

by:sqlcurious
ID: 39334919
Hi DcpKing and PAtelAlpesh, thanks a lot for your advice, I will give a try
0
 

Author Closing Comment

by:sqlcurious
ID: 39696803
thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

840 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