?
Solved

help with ssis package

Posted on 2013-06-20
4
Medium Priority
?
227 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 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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 setup several different housekeeping processes for a SQL Server.
Suggested Courses

764 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