Map SSIS variable inside Script task

 

 

 

 

 

C#

using System;using System.Data;using Microsoft.SqlServer.Dts.Runtime;

public class ScriptMain{

    public void Main()    {        int customerCount;        int maxRecordCount;

        if (Dts.Variables.Contains("CustomerCount")==true&&Dts.Variables.Contains("MaxRecordCount")==true)

        {            customerCount = (int) Dts.Variables["CustomerCount"].Value;            maxRecordCount = (int) Dts.Variables["MaxRecordCount"].Value;

        }

        if (customerCount>maxRecordCount)        {            Dts.TaskResult = (int)ScriptResults.Failure;        }        else        {            Dts.TaskResult = (int)ScriptResults.Success;        }

    }

}

 

 

 

Visual Basic

Public Sub Main()

    Dim customerCount As Integer    Dim maxRecordCount As Integer

    If Dts.Variables.Contains("CustomerCount") = True AndAlso _        Dts.Variables.Contains("MaxRecordCount") = True Then

        customerCount = _            CType(Dts.Variables("CustomerCount").Value, Integer)        maxRecordCount = _            CType(Dts.Variables("MaxRecordCount").Value, Integer)

    End If

    If customerCount > maxRecordCount Then            Dts.TaskResult = ScriptResults.Failure    Else            Dts.TaskResult = ScriptResults.Success    End If

End Sub

 

2 Comments for “Map SSIS variable inside Script task”

says:

Your article hepeld me get a few steps further but now i’m stuck again. Package runs ok. security is server storage but when scheduled job runs it complains about not finding the wsdl file for my web service.Started: 1:41:24 PM Error: 2009-03-30 13:41:41.05 Code: 0xC002F304 Source: Web Service Task 1 Web Service Task Description: An error occurred with the following error message: Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException: The input Web Services Description Language (WSDL) file is not valid. at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTaskUtil..ctor(Object connection, String downloadedWSDL) at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTask.executeThread() . End Error DTExec: The package execution returned DTSER_SUCCESS (0). Started: 1:41:24 PM Finished: 1:41:41 PM Elapsed: 16.391 seconds. The package executed successfully. The step succeeded.Running the package directly does not cause a problem with the wsdl file. I think the job can’t find it but don’t understandy why?Anyone run into this before ?

Leave a Reply