Solved

SSIS - how to use DestinationVariabke in a File System Task

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Viewers will learn how the fundamental information of how to create a table.
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.

734 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