Solved

SSIS - how to use DestinationVariabke in a File System Task

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now