Iterating inside a script task - SSIS 2012

Hi,
in order to create SSAS partitions I need to read a SQL Server table where I've year and month value.
So I think to iterate for each row inside the data set returned by the read operation and for each year and month value to create a SSAS partition.
Is it better to read the SQL Server table outside the script task? How can I iterate for each row in the dataset inside the script component?
Any suggests to me, please?
Thanks

I've done similar requirement as below
1. Create a object type variable
2. Use Execute sql task to populate the recordset with partition information from the query. Use resultset option as Full resultset and map to object variable with index 0 in resultset tab
3. Use a For Each Loop with ADO enumerator and map to object variable. Then have variables inside to get individual field values
4. Add script task inside loop and pass the variables inside and use it to build your script task for partition processing. If you want you can also use analysis services DDL task for this too.
Also see these for more info
http://aniruddhathengadi.blogspot.in/2012/07/automate-creation-of-cube-partitions.html
http://dataqueen.unlimitedviz.com/2014/05/how-to-automate-ssas-cube-partitioning-in-ssis/
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • The binary code for the script is not found error for the Script component - SSIS 2012

    Hi,
    I'm implementing a SSIS 2012 pkg. For a data flow task, I'm using a Visual Basic 2010 script component with an Oracle input flow. For the script component I've an input column and I've created an output column. Inside the script code I've edited only inside
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer).
    The written code is:
    If Year(Row.OFFDATAORI) < 1900 Then
    Row.OFFDATAORIconv = CDate(CStr("1900" + "-" + Right("00" + CStr(Month(Row.OFFDATAORI)), 2) + "-" + Right("00" + CStr(DatePart(DateInterval.Day, Row.OFFDATAORI)), 2))
    Else : Row.OFFDATAORIconv = Row.OFFDATAORI
    End If
    It is to note that OFFDATAORI isn't the name of the input column for the script component.
    When I close the script component I've an error about "The binary code for the script is not found".
    Any helps to me, please?
    Thanks

    Hi,
    I've solved. There was a syntax error, a bit hidden.
    Bye

  • Web Reference inside Script Task causes Binary code for script not found error

    I am attempting to access a SOAP web API (sales force) from a SSIS package. To do this I created a script task.
    Inside the script task I went to Add Service Reference. Then I click advanced to make it a web reference. Then I point it to the WSDL file and give it a name SFEnterprise. It successfully finds and adds the Web Reference to the script task.
    I leave scriptMain.cs alone and I have no warnrings and no errors. Now in the solution explorer I right-click the script task and hit BUILD. I see the message from Output that BUILD succeeded.
    I close the VSTA script editor and now I am back on the control flow window. However I have a red X on the script task with the following message. "The Binary code for the script is not found. Please open the script in the designer by clicking EditScript
    button and make sure it builds successfully"
    But it does build successfully! And I have not even added any custom code except for the web reference using the WSDL file.
    I am using SSIS 2012 and Visual Studio 2012. I have been reading about this binary code error message on Google searches and suggestions about delay validation and turning off pre-compile do not apply to SSIS 2012.
    Is SSIS not capable of doing this?

    I was wanting to use the 2.0 coding style of accessing the soap service which is supported by adding the web reference vs. adding a service reference. But using a service reference instead of web reference actually allows the script task to compile. This
    is really odd behavior. I wonder why one works and not the other.
    Changing my C# code over to service reference coding style to access the SOAP service was still returning an error. When I added a break point I found the error message "Could not find default endpoint element that references contract in the ServiceModel
    client configuration section"when calling new SoapClient();
    I found this page http://www.sqlis.com/sqlis/post/Where-is-my-appconfig-for-SSIS.aspx and after I copied the System.ServiceModel app settings from the script task app.config to the DTSDebugHost.exe.config it was able to successfully login to the endpoint
    during package debug mode.
    This means I will have to edit the SQL Server DTS config files on the prod SSIS server to get the package to actually run in the job agent.
    So for now I am good I think just plugging away at coding what the script task is actually supposed to do now that is can actually login.

  • SSIS 2005 Script task to process XMLA

    Hi,
    I am looking for a script (in script task SSIS 2005) to execute the XMLA command.This needs to be done through script only as my Analysis DDL task is having issue with connection.Please let me know,if any one can help me on this.
    Thanks,
    Ramesh

    Not sure whats the issue with your connection but we usually make use of dynamic XMLA scripts generated using script task and pass them onto Analysis services ddl task to create partitions. Similarly we use analysis services processing task to process the
    created partitions. If you can give more details on issue we may be able to help you out.
    Alternatively, if you want a solution using only script task have a look at the below
    http://bishtabhinav.wordpress.com/2012/06/01/cube-processing-using-ssis/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Script task fails to send mail to GMAIL

    Hi   guys ,
       I am new here and i am glad i that i am here.  I am working in a company  as SQL Server developer(T-sql), i am learning SSIS because  i wanted to move to data warehousing.
    I not familiar and i don't know any thing about  C#,  but i am learning SSIS on my own.
    I tried to send mail to gmail  using script task , both sender and receiver with same mail ID using variables which i tried using tutorial i found from the below link.
    [quote]http://www.codeproject.com/Articles/85172/Send-Email-from-SSIS-with-option-to-indicate-Email[/quote]
    but finally when i execute the task , it returns failure message and email is not sent.
    [quote]SSIS package "Send mail using script task.dtsx" starting.
    Error: 0x8 at Script Task: The script returned a failure result.
    Task failed: Script Task
    SSIS package "Send mail using script task.dtsx" finished: Success.
    [/quote]
    Below message taken from progress tab
    [quote]Error: The script returned a failure result.[/quote]
    Can you all please help me in  finding where i am going wrong? please check below code which i have used in script task.
    Microsoft SQL Server Integration Services Script Task
    Write scripts using Microsoft Visual C# 2008.
    The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.Text.RegularExpressions;
    using System.Net.Mail;
    namespace ST_9bc84810a62a401aa44ddd905bcd369d.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    #region VSTA generated code
    enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    #endregion
    The execution engine calls this method when the task executes.
    To access the object model, use the Dts property. Connections, variables, events,
    and logging features are available as members of the Dts property as shown in the following examples.
    To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
    To post a log entry, call Dts.Log("This is my log text", 999, null);
    To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
    To use the connections collection use something like the following:
    ConnectionManager cm = Dts.Connections.Add("OLEDB");
    cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
    Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    To open Help, press F1.
    public void Main()
    string sSubject = "Test Subject";
    string sBody = "Test Message";
    int iPriority = 2;
    if (SendMail(sSubject, sBody, iPriority))
    Dts.TaskResult = (int)ScriptResults.Success;
    else
    //Fails the Task
    Dts.TaskResult = (int)ScriptResults.Failure;
    public bool SendMail(string sSubject, string sMessage, int iPriority)
    try
    string sEmailServer = Dts.Variables["sEmailServer"].Value.ToString();
    string sEmailPort = Dts.Variables["sEmailPort"].Value.ToString();
    string sEmailUser = Dts.Variables["sEmailUser"].Value.ToString();
    string sEmailPassword = Dts.Variables["sEmailPassword"].Value.ToString();
    string sEmailSendTo = Dts.Variables["sEmailSendTo"].Value.ToString();
    string sEmailSendCC = Dts.Variables["sEmailSendCC"].Value.ToString();
    string sEmailSendFrom = Dts.Variables["sEmailSendFrom"].Value.ToString();
    string sEmailSendFromName = Dts.Variables["sEmailSendFromName"].Value.ToString();
    SmtpClient smtpClient = new SmtpClient();
    MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress(sEmailSendFrom, sEmailSendFromName);
    //You can have multiple emails separated by ;
    string[] sEmailTo = Regex.Split(sEmailSendTo, ";");
    string[] sEmailCC = Regex.Split(sEmailSendCC, ";");
    int sEmailServerSMTP = int.Parse(sEmailPort);
    smtpClient.Host = sEmailServer;
    smtpClient.Port = sEmailServerSMTP;
    System.Net.NetworkCredential myCredentials =
    new System.Net.NetworkCredential(sEmailUser, sEmailPassword);
    smtpClient.Credentials = myCredentials;
    message.From = fromAddress;
    if (sEmailTo != null)
    for (int i = 0; i < sEmailTo.Length; ++i)
    if (sEmailTo[i] != null && sEmailTo[i] != "")
    message.To.Add(sEmailTo[i]);
    if (sEmailCC != null)
    for (int i = 0; i < sEmailCC.Length; ++i)
    if (sEmailCC[i] != null && sEmailCC[i] != "")
    message.To.Add(sEmailCC[i]);
    switch (iPriority)
    case 1:
    message.Priority = MailPriority.High;
    break;
    case 3:
    message.Priority = MailPriority.Low;
    break;
    default:
    message.Priority = MailPriority.Normal;
    break;
    //You can enable this for Attachments.
    //SingleFile is a string variable for the file path.
    //foreach (string SingleFile in myFiles)
    // Attachment myAttachment = new Attachment(SingleFile);
    // message.Attachments.Add(myAttachment);
    message.Subject = sSubject;
    message.IsBodyHtml = true;
    message.Body = sMessage;
    smtpClient.Send(message);
    return true;
    catch (Exception ex)
    return false;
    Please help me resolve this guys ... THANKS IN ADVANCE

    Thank you very much for your reply @Elvis Long,
    Sorry for the late reply
    Actually, i am not trying or executing this task  from my office , but i am trying this at my home :( .
    sEmailPort has value 587 sEmailServer has smtp.gmail.com
    Can you please check whether this C# coding is correct or not ? because finally it gives error saying "Script
    Task: The script returned a failure result" 
    so can you please check this with your system and let me know what is wrong with this code
    Thanks in advance  

  • Is it a bug - SSIS 2012 ReadOnlyVariables in Script Task doesn't work

    It's very weird when I use the ReadOnlyVariables in SSIS 2012 Script Task, it doesn't work at all!!! And I never notice this change before, but everything in 2008 R2 is fine! Is it a bug in SSIS 2012 ?
    All the variables I set them to "ReadOnlyVariables"
    In scripts - I assigned some values from system variables.
    String PackageName = Dts.Variables["System::PackageName"].Value.ToString();
    DateTime CurrentDate = (DateTime)Dts.Variables["System::StartTime"].Value;
    // User Defined Variables
    Dts.Variables["User::PV_CURRENT_DATE"].Value = CurrentDate;
    Dts.Variables["User::PV_YEAR"].Value = CurrentDate.Year;
    Dts.Variables["User::PV_MONTH"].Value = CurrentDate.Month;
    Dts.Variables["User::PV_DAY"].Value = CurrentDate.Day;
    Dts.Variables["User::PV_PACKAGE_NAME"].Value = PackageName;
    Execute the package, it works !
    The only thing I can make it as SSIS 2008 R2 does is to change the ReadOnly for each variables.
    Then you will get the error.
    Why do we need this feature here but not to use the ReadOnlyVariables in script task ?
    Please vote if it's helpful and mark it as an answer!

    I can reproduce it as well. Feels like a bug...
    Locking the variable for read in code has the same effect:
    public void Main()
    // Lock variable for read
    Dts.VariableDispenser.LockForRead("User::myStringVariable");
    // Create a variables 'container' to store variables
    Variables vars = null;
    // Add variable from the VariableDispenser to the variables 'container'
    Dts.VariableDispenser.GetVariables(ref vars);
    // Now try giving it a new name
    vars["User::myStringVariable"].Value = "new value";
    // Release the locks
    vars.Unlock();
    Dts.TaskResult = (int)ScriptResults.Success;
    For reference:
    https://connect.microsoft.com/SQLServer/Feedback/Details/991697
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • SSIS script task using visual c# 2012 language when creating package in Visual Studio 2013

    Is it right or my installation was all wrong.
    When I am trying to use a script task in an SSIS package using Visual Studio 2013, the available languages are visual c# and VB 2012.
    I was expecting to find visual c# and VB 2013 since I was using Visual Studio 2013.
    I already installed the "Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2013" available for sql 2014
    Please help clarify this. Thanks beforehand.
    Paulino

    Hi Paulino,
    According to your description, the ScriptLanguage property of C# script tasks show "Microsoft Visual C# 2012” in SSDT-BI for VS 2013.
    After testing the issue in my environment, I can reproduce it in SSDT-BI for VS 2013. And I find that the ScriptLanguage property of C# script tasks show "Microsoft Visual C# 2010” in SSDT, and show "Microsoft Visual C# 2012” in SSDT for SSDT –
    BI for VS2012. It only appear in SSDT-BI for VS 2013.
    The issue is by design. But we can check "Do not show this again." to ignore the dialog and the task can be executed without any problem.
    The following feedback is for your reference:
    https://connect.microsoft.com/SQLServer/feedback/details/1027035/ssdt-bi-for-vs-2013-compatibility-issue
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • When migrating ssis packages from 2005 to 2012 Activex Script Task component doesn't exist in 2012 version

    Hello,
    We are migrating the ssis packages from 2005 to 2012.
    I'm unable to convert Activex Script Task from 2005 vesrsion to 2012 because in 2012 version Activex Script Task doesn't exist.
    Can anyone please let me know what is the alternative way to convert Activex Script Task from 2005 vesrsion to 2012?

    Hi Vinay9738,
    Have you tried to upgrade the SSIS 2005 packages to SSIS 2012 packages by using the SSIS Package Upgrade wizard? In certain cases, ActiveX script in SSIS won’t work and we need to either modify the script or replace the ActiveX Script with stock SSIS
    tasks. You can find the mapping between some most common patterns used in DTS ActiveX Script and SSIS native tasks from the following link:
    http://help.pragmaticworks.com/dtsxchange/scr/ActiveX%20Script%20Task.htm
    Here is also a useful link about how to convert ADODB object of ActiveX Script to SSIS tasks:
    http://help.pragmaticworks.com/dtsxchange/scr/FAQ%20-%20How%20to%20convert%20ADODB%20object%20of%20ActiveX%20Script%20to%20native%20SSIS%20Task.htm
    Regards,
    Mike Yin
    TechNet Community Support

  • SSIS 2012 Script Task Debugging not working (VSTA Popup but no script displayed in IDE)

    Hi,
    I am trying to debug 2012 SSIS Package but for some reason its not working. Basically when I run package (64bit mode) it pop up Script IDE but never brings up Script (see below). Usually when debugging of script starts it should break execution at the code.
    Anybody experienced this issue with SSIS 2012 ?
    Thanks,
    Nayan
    Visit My Blog (Home of BI Articles) 

    Hi,
    I am trying to debug 2012 SSIS Package but for some reason its not working. Basically when I run package (64bit mode) it pop up Script IDE but never brings up Script (see below). Usually when debugging of script starts it should break execution at the code.
    Anyone has clue whats going on here?
    Thanks,
    Nayan
    My Blog |
    Convert DTS to SSIS |
    Document SSIS |
    SSIS Tasks |
    Real-time SSIS Monitoring

  • SSIS 2012 Script Task to Get File Properties

    Hello,
    I researched on how to grab a file properties such as file size, file modified date, etc and I came across the following
    link:
    I followed exact steps and when I went to execute the package, I got the following error:
    Below is the code:
    // C# code
    // Fill SSIS variables with file properties
    using System;
    using System.Data;
    using System.IO; // Added to get file properties
    using System.Security.Principal; // Added to get file owner
    using System.Security.AccessControl; // Added to get file owner
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_cb8dd466d98149fcb2e3852ead6b6a09.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    #region VSTA generated code
    enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    #endregion
    public void Main()
    // Lock SSIS variables
    Dts.VariableDispenser.LockForRead("User::FilePath");
    Dts.VariableDispenser.LockForWrite("User::FileAttributes");
    Dts.VariableDispenser.LockForWrite("User::FileCreationDate");
    Dts.VariableDispenser.LockForWrite("User::FileExists");
    Dts.VariableDispenser.LockForWrite("User::FileInUse");
    Dts.VariableDispenser.LockForWrite("User::FileIsReadOnly");
    Dts.VariableDispenser.LockForWrite("User::FileLastAccessedDate");
    Dts.VariableDispenser.LockForWrite("User::FileLastModifiedDate");
    Dts.VariableDispenser.LockForWrite("User::FileOwner");
    Dts.VariableDispenser.LockForWrite("User::FileSize");
    // Create a variables 'container' to store variables
    Variables vars = null;
    // Add variables from the VariableDispenser to the variables 'container'
    Dts.VariableDispenser.GetVariables(ref vars);
    // Variable for file information
    FileInfo fileInfo;
    // Fill fileInfo variable with file information
    fileInfo = new FileInfo(vars["User::FilePath"].Value.ToString());
    // Check if file exists
    vars["User::FileExists"].Value = fileInfo.Exists;
    // Get the rest of the file properties if the file exists
    if (fileInfo.Exists)
    // Get file creation date
    vars["User::FileCreationDate"].Value = fileInfo.CreationTime;
    // Get last modified date
    vars["User::FileLastModifiedDate"].Value = fileInfo.LastWriteTime;
    // Get last accessed date
    vars["User::FileLastAccessedDate"].Value = fileInfo.LastAccessTime;
    // Get size of the file in bytes
    vars["User::FileSize"].Value = fileInfo.Length;
    // Get file attributes
    vars["User::FileAttributes"].Value = fileInfo.Attributes.ToString();
    vars["User::FileIsReadOnly"].Value = fileInfo.IsReadOnly;
    // Check if the file isn't locked by an other process
    try
    // Try to open the file. If it succeeds, set variable to false and close stream
    FileStream fs = new FileStream(vars["User::FilePath"].Value.ToString(), FileMode.Open);
    vars["User::FileInUse"].Value = false;
    fs.Close();
    catch (Exception ex)
    // If opening fails, it's probably locked by an other process
    vars["User::FileInUse"].Value = true;
    // Log actual error to SSIS to be sure
    Dts.Events.FireWarning(0, "Get File Properties", ex.Message, string.Empty, 0);
    // Get the Windows domain user name of the file owner
    FileSecurity fileSecurity = fileInfo.GetAccessControl();
    IdentityReference identityReference = fileSecurity.GetOwner(typeof(NTAccount));
    vars["User::FileOwner"].Value = identityReference.Value;
    // Release the locks
    vars.Unlock();
    Dts.TaskResult = (int)ScriptResults.Success;
    Eventually I am looking to just grab the Modified Date from the Windows Explorer folder and insert into table. Any suggestions? Thank you in advance!
    Sanjeev
    Sanjeev Jha

    Hi SSISJoost,
    I am so glad you responded to this thread. You are absolutely right. I copied the entire code including the project name (guid) and that solved the error problem.
    Now, what did you do to get the message box? I added the watch and I could see the values but how do I get these values in a table? If I remember correctly, in your blog, you mentioned something about using derived columns. I am familiar with Derived Columns
    but how do I do that? I appreciate your response.
    Thank you.
    Sanjeev
    Sanjeev Jha
    I used a second script task to show all variable values. It has a
    MessageBox in it and between all
    variables I added a
    newline to make it more readable...
    But with an Execute SQL Task and parameters you can also put these values in a Table... or you can read the file in a Data Flow Task and add those variables (as metadata) to each record with a Derived Column
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Scripting Language Options for the Script Task Options SSIS 2012

    Can python or perl be used as a script language in the drag and drop script task? I believe only VB.Net and C# are, but I see under SSDT Tools -> Options there are some choices for Python Debugging? I'd like to use python as my SSIS scripting language
    in some cases. If it can not be used as the script task language, what are the Python options under Tools -> Options for?
    Any experts out there who can illuminate?
    Thanks all

    Hello,
    In SSDT in a SSIS Script task you can only use Visual Basic.NET and C#, no other programming / scripting languages.
    SSDST is a plugin for Visual Studio and in VS you will find several options which are irrelevant for SSIS projects, like this Phyton debugging option.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Script task error during the creation of partition by reading a table and using AMO - SSAS 2012

    Hi,
    I need to create SSAS (tabular) and process partitions in an authomatic manner. Moreover, the partitioning is respect to a category, an year and a month.
    Category, year and month are resident on a table to read to create the SSAS partitions.
    So, in a SSIS pkg:
    a. I've created a data flow task to read the SQL Server table having category, year and month data,
    b. I've connected the output of the ole db source as the input for a recordset destination, associated to an object variable,
    c. I've used a for each loop container (ado enumerator) specifying the object variable and three variables, for category, year and month,
    d. inside the for each loop container I've created a script task using AMO (visual basic) to control for any existing partitions, if not presents to create the new ones and then to process them.
    For the first iteration, a new partition has been created and processed successfully, but then, for other category, year and month values the script task fails. I've controlled the code many times and I've tried to put returning messageboxes but I've found
    anything. The error is a generic one and no other info are returned.
    Well, any suggests to me in order to solve this issue, please?
    Many thanks

    Hi, thanks, I've solved adding to the code end the SSAS server connection termination.
    Bye

  • SSIS : Read Rows from an Object variable in SSIS Script Task which is looped many times.

    Hello All,
    Here is what I am trying to do...
    1. I am having two rows, one column in an Object Variable. (vLoopCountObj).
    2. I am having 30 Rows, 2 Columns in my second Object  Variable (vTableRowsObj)
    3. I have a FOR EACH LOOP which will run for number of rows in vLoopCountObj i.e 2 times here.
    4. I have a Script Task inside the FOR EACH LOOP to display all the rows of vTableRowsObj.
    5. When I execute, 30 Rows gets displayed only once. It will not display when the loop goes for second iteration. Please help me to display for second time.
    6. I have used below code to display the rows whithin the script task which is in SSIS dataflow task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Collections
    Imports System.Data.OleDb
    Public Class ScriptMain
    Public Sub Main()
    Dim oleDA As New OleDbDataAdapter
    Dim dt As New DataTable
    Dim col As DataColumn
    Dim row As DataRow
    Dim sMsg As String
    oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
    MsgBox("Number of Rows " + dt.Rows.Count.ToString())
    For Each row In dt.Rows
    For Each col In dt.Columns
    sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
    Next
    MsgBox(sMsg)
    sMsg = ""
    Next
    Dts.TaskResult = Dts.Results.Success
    End Sub
    End Class

    Hi Raj,
    It is verrrry interesting issue. I can also confirm that it doesnt loop again. I've made a simple test and figured that in the second loop even you fill the Dataadapter, record count is zero. Which brings me up to the idea: Somehow, after you read the object
    variable resultset, you can not read it again in the for each loop.
    Strange, probably a bug or a technical issue that is beyond my existing knowledge.
    I can provide a workaround. You can also loop in script task for first variable. (Nested loops)
    Let other members to examine and comment on this.
    Regards
    Onur
    (For others who also wants to test, here is my scenario
    Execute SQL Task 1:
    Query: SELECT 1 as Cnt UNION ALL SELECT 2 as Cnt
    Resultset: Full Resultset
    ResultSet Tab: Name: 0, Variable Name: User::vLoopCountObj;
    Execute SQL Task 2:
    Query: SELECT 1 as ColA, 2 as ColB UNION ALL SELECT 3 as ColA, 4 as ColB UNION ALL SELECT 5 as ColA, 6 as ColB
    Resultset: Full Resultset
    ResultSet Tab: Name: 0, Variable Name: User::vTableRowsObj;
    For Each Loop Container:
    Collection: Enum: ForEach ADO Enum
    Source Object: User::vLoopCountObj
    Enum Mode: Rows n the first Table
    Script Task:
    ReadOnlyVariables: User::vTableRowsObj
    Script Source:
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Collections
    Imports System.Data.OleDb
    Public Class ScriptMain
    Public Sub Main()
    Dim oleDA As New OleDbDataAdapter
    Dim dt As New DataTable
    Dim col As DataColumn
    Dim row As DataRow
    Dim sMsg As String
    oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
    Dts.Events.FireInformation(-1, "START!!!!!!!!!!!!!!", "START LOOP", "", 0, True)
    Dts.Events.FireInformation(1, "RowCount: ", dt.Rows.Count.ToString(), "", 0, True)
    For Each row In dt.Rows
    For Each col In dt.Columns
    sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
    Next
    Dts.Events.FireInformation(1, "Msg: ", sMsg, "", 0, True)
    sMsg = ""
    Next
    Dts.TaskResult = ScriptResults.Success
    End Sub
    End Class
    BI and ERP Senior Consultant @ Nexum Bogazici
    If it is, Please dont forget to mark as answered or at least vote as helpful if the post helps you in any ways.

  • HELP: SSIS 2012 - Execute SQL Task with resultset to populate user variables produces DBNull error

    I am experiencing an unexplainable behavior with the Execute SQL Task control in SSIS 2012. The following is a description of how to simulate
    the issue I will attempt to describe:
    1. Create a package and add two variables User::varTest1 and User::varTest2 both of String type with default value of "Select GetDate()"
    for each, have shown this to not matter as the same behavior occurs when using a fixed string value or empty string value.
    2. Add a new Execute SQL Task to the control flow.
    3. Configure an OLE DB connection.
    4. Set SQLSourceType = "Direct Input"
    5. Set the ResultSet property of the task to "Single Row"
    6. In the ResultSet tab add two results as follows: 
    Result Name: returnvalue1, Variable Name: User::varTest1
    Result Name: returnvalue2, Variable Name: User::varTest2
    7. Set an expression for the SqlStatementSource property with a string value of "Select 'Test' returnvalue1, 'Testing' returnvalue2'"
    The idea is that the source would be dynamically set in order to run a t-sql statement which would have dynamic values for database name
    or object that would be created at runtime and then executed to set the user variable values from its resultset. Instead what occurs is that a DBNull error occurs.
    I am not sure if anyone else has experienced this behavior performing similiar actions with the Execute SQL Task or not. Any help would be
    appreciated. The exact message is as follows:
    [Execute SQL Task] Error: An error occurred while assigning a value to variable "varRestoreScript": "The type of the value
    (DBNull) being assigned to variable "User::varRestoreScript" differs from the current variable type (String). Variables may not change type during execution. Variable types are strict, except for variables of type Object.
    User::varRestoreScript is the first return value. And even with the a dummy select the same result occurs. I have narrowed the issue down
    to the T-SQL Statement structure itself. 
    The following works just fine within the execute sql task control as long as no resultset is configured for return:
    "Declare @dynamicSQL nvarchar(max)
    Select @dynamicSQL = name 
    From sys.databases 
    Where name = 'master'
    Select atest_var1=@dynamicSQL, atest_var2='static'"
    I have tried various iterations of the script above with no success. However, if I use the following derivative of it the task completes
    successfully and variables are set as expected.  This will not work for my scenario however as I need to dynamically build a string spanning multiple resultsets to build one of the variable values.
    "Select atest_var1=name, atest_var2='static'
    From sys.databases
    Where name = 'master'
    I have a sample package which can reproduce this issue using the above code.  You can get to that through the post on www.sqlservercentral.com/Forums/Topic1582670-364-1.aspx
    Scott

    Arthur,  the query when executed doesn't return a null value for the @dynamicSQL variable.  It returns "master" as a string value.  Even the following fails which implements that suggestion:
    Declare @dynamicSQL as nvarchar(max)
    Select @dynamicSQL = name
    From master.sys.databases 
    Where name = 'master' -- (or any other DB name)
    I believe I have found the cause of the issue.  It is datatype and size related.  The above script will properly set the variables in the resultset as long as you don't use nvarchar(max) or varchar(max).  This makes the maximum data size for
    a String variable 4000 characters whether unicode or non-unicode typed.

  • How adding a data source-data destination inside SSIS 2012-SSDT

    Hi,
    I need to see inside a SSIS 2012 project a new SSIS installed component but in the SSDT 2010 I cannot see the SSIS Data Flow Items tab for adding data source/data destination respect to the choose toolbox items pane:
    It seems a SSIS bug.
    Any helps to me, please?
    Thanks

    Hi,
    In SQL 2012 you are no longer required to manually pick the tasks and components you want to use. You have to select from the new custom SSIS Toolbox to use the additional components you need.
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

Maybe you are looking for

  • Internet Connection Slow on Macbook Pro (Mid 2010)

    All of the sudden, this past week, my internet has been running quite slow on my Macbook Pro.  This problem is with the Macbook itself and not with the internet connection (I have connected to various networks and my other wifi devices run well on th

  • ISE 1.2 anomalous client suppression

    Is there a way to clear a client who has been flagged as an anomalous client ? We are hesitent to modify or change any of the settings without fully understanding the potential impact, but would like to know if there is a way to manually reset a clie

  • Adobe Flash Player 10 reports download, is not in Flash Folder?

    I have uninstalled and installed Adobe Flash Player 10.2 on my Windows XP sp3 system using the both the DLM installer and the manual installer.  I have adjusted the firewall and security settings and have determined that no windows are open with Wind

  • Http to Abap Proxy communication with multiple queues generation in Recevr

    Dear SDNs, I need some help in the following scenario, appreciate your suggestions and help . I am receiving the messages from sender to PI on http posting, from PI  I am sending the message to SAP system using receiver xi communication channel ( rec

  • Annoyingly Helpful

    I decided to try speech recognition on my laptop running Win7.  Now, every time I open a pdf with Adobe reader, it wants to read the document to me.  How can I turn this annoying feature off?  It happens even when I don't have speech recog turned on.