Solved

help with ssis package

Posted on 2013-06-20
4
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

689 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