Solved

help with ssis package

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Some sers suddenly getting error popup msg 28 89
Query Help - MSSQL - Averages 5 27
SQL Error - Query 6 25
Replace the integer portion in CAST with a column 4 15
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.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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

770 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