How to Use Variables in Script Task in SSIS Package (C# and VB NET Scripting Language) - SQL Server Integration Services(SSIS) Tutorial

In this video we will learn about usage of variables in Script Task in SSIS Package

How to create variables in SSIS Package
How to use variables as ReadOnlyVariables and ReadWriteVariables in Script Task
How to set the value of variable from Script Task in SSIS Package



How to use Variables in Script Task in SSIS Package by using C# Scripting Language

    public void Main()
        {

//Set the value of local variables in SSIS Script from SSIS Variables
            string FileName;
            string FolderPath;

            FileName=Dts.Variables["User::FileName"].Value.ToString();
            FolderPath = Dts.Variables["User::SourceFolder"].Value.ToString();
            

//Set the Value of variable from Script Task in SSIS Pacakge
 Dts.Variables["User::FileFullPath"].Value = FileName + FolderPath + "I have set value";
            MessageBox.Show(Dts.Variables["User::FileFullPath"].Value.ToString());
            Dts.TaskResult = (int)ScriptResults.Success;
        }

How to use Variables in Script Task in SSIS Package by using VB NET Scripting Language

   Public Sub Main()
        Dim filename As String
        Dim SourceFolder As String
'Set the value of local variables in SSIS Script from SSIS Variables
        filename = Dts.Variables("User::FileName").Value.ToString()
        SourceFolder = Dts.Variables("User::SourceFolder").Value.ToString()


'Set the Value of variable from Script Task in SSIS Pacakge
        Dts.Variables("User::FileFullPath").Value = SourceFolder + filename
        MessageBox.Show(Dts.Variables("User::FileFullPath").Value.ToString())
        ' Add your code here
        '
        Dts.TaskResult = ScriptResults.Success
    End Sub


How to use Variables in Script Task in SSIS Package by using C# or VB.NET Scripting Language



    Related Posts/Videos on Script Task    


1 comment:

  1. Thank you for sharing your blog which enhances our knowledge and students career sector. I want to aware you towards our Online Education platform, content is valuable, it help in developing knowledge it’s too worthy
    rpa training in chennai

    ReplyDelete

Note: Only a member of this blog may post a comment.