Solved

help with ssis package

Posted on 2013-06-20
4
200 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 250 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 250 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Suggested Solutions

My client sends data in an Excel file to me to load them into Staging database. The file contains many sheets that they have same structure. In this article, I would like to share the simple way to load data of multiple sheets by using SSIS.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

708 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

16 Experts available now in Live!

Get 1:1 Help Now