Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:20:18+00:00 2026-05-25T01:20:18+00:00

I have a script component in SSIS on SQLServer 2008 R2, that needs to

  • 0

I have a script component in SSIS on SQLServer 2008 R2, that needs to be able to write to a Read-Write variable to produce a file name for a flat file export. I created a package level variable to hold the file name, and set the flat file connection to use an expression containing the variable..

I have a script component that, among other things, builds the file name dynamically in the post execute method. I’ve set the variable in the ReadWriteVariables setting of the script component.

The package will immediately fail if I don’t have a default value in the variable, because the flat file connection manager tries to evaluate the expression to set up the destination file. So, I just put in a placeholder file name.

The problem is that now it always uses the placeholder filename instead of the one that the script specifies. What’s the best way to make sure that I can write to those variables? I tried Variables.VariableName = “value”, I’ve also tried using VariableDispenser and this.ReadWriteVariables[“VariableName”].value, and none of them are persisting the value I set in the script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:20:18+00:00Added an answer on May 25, 2026 at 1:20 am

    Here is one way you can assign value to a package variable from within Script Component available inside Data Flow Task.

    I try to lock the variables inside the Script Task or Script Component instead of specifying them on Properties dialog. I feel this is easier to maintain.

    In the following example, I have a package variable named FileName and the variable is being assigned with the value C:\Temp\PathChanged inside the Script Component.

    I believe that Script Component may not be the right place to manipulate the package variable value such as file name but again that depends on what you are trying to do.

    Hope that helps.

    /* Microsoft SQL Server Integration Services Script Component
    *  Write scripts using Microsoft Visual C# 2008.
    *  ScriptMain is the entry point class of the script.*/
    
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    
    [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
    public class ScriptMain : UserComponent
    {
        public override void PreExecute()
        {
            base.PreExecute();
        }
    
        public override void PostExecute()
        {
            base.PostExecute();
    
            IDTSVariables100 varCollection = null;
            this.VariableDispenser.LockForWrite("User::FileName");
            this.VariableDispenser.GetVariables(out varCollection);
    
            varCollection["User::FileName"].Value = @"C:\Temp\PathChanged";
        }
    
        public override void Input0_ProcessInputRow(Input0Buffer Row)
        {
        }
    }
    

    Script Component

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that takes a table name and generates a control file
I have a SSIS 2008 script component which is setup as a transform (so
I have an SSIS package that runs a script component as one step in
I have an SSIS 2008 script component and it uses the method Input0_ProcessInputRow(Input0Buffer Row)
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I have an SSIS script component which takes in rows from input. One of
I have a problem while executing a SSIS script component. To be honest I
I have a script component which I need to reference a global variable? I
I have a Data Flow Task that does some script component tasks, sorts, then
I have a html component that includes some javascript. The component is a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.