Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SSIS - how to use DestinationVariabke in a File System Task

Posted on 2007-11-13
5
Medium Priority
?
1,885 Views
Last Modified: 2013-11-30
Hi,
I am using a File System task in SSIS. My source file is a standard xls output file. i have a for loop container and in this container i have a variable. I need to somehow in the File System task add this variable to the output name of my xls doc.

so lets say my source file is Trn Extract.xls - now based on the current variable value in my for loop container, lets say its currently X
then i need my Destination file name must be "X Trn Extract.xls" and so on so the next one would then use the same source file and the next value of the variable would then be "Y Trn Extract.xls"

Now i have set the IsDestinationPathVariable to True
but i am not sure how to then set the DestinationVariable to my output directory including the variable as part of the file name

hope this makes sense


thanks
0
Comment
Question by:CraigLazar
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:frankytee
ID: 20277827
are you using a simple "transform data task" to create your excel file? if so then the variable would be out of scope with the task. either create an active x script to do the extract where you can use your variable, or rename the file after creating it by using one the reserved sql stored proces (something like xp_rename etc) but you would need to insert the variable into an sql table and then read from this sql table when renaming the file.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 20278050
Hi,
i am using a Data flow task where i have an OLE DB source being my Qry then to an Excel Destination task. Once the file is created i am then using the FileSystem task to rename the file thats just been created
0
 
LVL 19

Accepted Solution

by:
frankytee earned 375 total points
ID: 20286733
i think the term FileSystem task is for sql 2005 which i haven't used but since you are renaming the file in this task i would assume it has the ability to communicate with your package variables.
If not then you would need to create an active x script (using either vb script or jscript) and associate your file to the variable. eg below, replace names accordingly.

Function fnGetVariable()
    Dim pkg
    dim s  
    Set pkg = DTSGlobalVariables.Parent
    s = DTSGlobalVariables("whatevervariable").Value
   'now rename your file with this variable
      ....etc
End Function
0
 
LVL 19

Expert Comment

by:frankytee
ID: 20286770
in sql 2005 the syntax might be:
Dts.Variables.Item("whatevervariable").Value
rather than my previous post
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 20295813
Hi,
I figured it out,
I am just going to use a script object, and in there write code to manipulate my files they way i need to

thanks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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…
I have a large data set and a SSIS package. How can I load this file in multi threading?
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…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

916 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