Solved

SSIS - how to use DestinationVariabke in a File System Task

Posted on 2007-11-13
5
1,877 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 125 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

679 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