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

Similar Messages

  • 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

  • SQL 2008 R2 - SSIS C# Script Task - Not Setting Variable

    OK... I am stumped.  I am trying to set the variable "User::TicketDB_Get_SQL" from a Script Task since it is dynamic... and well it isn't working :(
    I can see I am supposed to be setting the value, but when I do breaks and watch that variable the new value is not being set.  Here is my C# code... Can someone look and see what the heck I might be doing wrong:
    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.IO;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using System.Text.RegularExpressions;
    namespace ST_3542610d50a64788be84926d15e07f7b.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()
    //MessageBox.Show("Start VB");
    //MessageBox.Show("Make ADO Connection");
    SqlConnection sqlConn = new SqlConnection();
    sqlConn = (SqlConnection)(Dts.Connections["ADO-DW-SSIS_Processing"].AcquireConnection(Dts.Transaction) as SqlConnection);
    SqlConnection sqlTicketDBRowsConn = new SqlConnection();
    sqlTicketDBRowsConn = (SqlConnection)(Dts.Connections["ADO-DW-SSIS_Processing"].AcquireConnection(Dts.Transaction) as SqlConnection);
    //MessageBox.Show("Connected to ADO");
    String newSelectSQL = null;
    //bool fireAgain = false;
    Variables vars = null;
    try
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_Max_Modified_Date");
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_Prod_Table");
    Dts.VariableDispenser.LockForRead("User::Modified_Date_Field");
    Dts.VariableDispenser.LockForRead("User::TicketDB_Schema");
    Dts.VariableDispenser.LockForRead("User::Table_Name");
    Dts.VariableDispenser.LockForRead("User::Unique_ID_Field");
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_Process_Table_Name");
    Dts.VariableDispenser.LockForRead("User::Data_Warehouse_DB_Name");
    Dts.VariableDispenser.LockForWrite("User::TicketDB_Get_SQL");
    Dts.VariableDispenser.LockForWrite("User::Reprocess_Records");
    Dts.VariableDispenser.GetVariables(ref vars);
    //Dts.VariableDispenser.GetVariables(ref glvars);
    String maxModDate = vars["User::Data_Warehouse_Max_Modified_Date"].Value.ToString();
    String prodtable = vars["User::Data_Warehouse_Prod_Table"].Value.ToString();
    String modField = vars["User::Modified_Date_Field"].Value.ToString();
    String TicketDBSchema = vars["User::TicketDB_Schema"].Value.ToString();
    String tablename = vars["User::Table_Name"].Value.ToString();
    String uniqIDField = vars["User::Unique_ID_Field"].Value.ToString();
    String procTable = vars["User::Data_Warehouse_Process_Table_Name"].Value.ToString();
    String custName = vars["User::Data_Warehouse_DB_Name"].Value.ToString();
    String Reprocess = "F";
    String ReprocessDate = "0";
    String ReprocessPrime = null;
    String ReprocessVal = null;
    Int16 count = 0;
    #region Get List of Rows for TicketDB Query
    String TicketDBRows = null;
    String sqlTicketDBRowsQuery = "SELECT [TicketDB_Column_Name] " +
    "FROM " + procTable + " " +
    "WHERE " +
    "[Import_Data_Warehouse] = 1 " +
    "AND " +
    "[TicketDB_Table_Name] = '" + tablename + "' " +
    "ORDER BY [TicketDB_Column_Name]";
    SqlCommand sqlTicketDBRowsCmd = new SqlCommand(sqlTicketDBRowsQuery, sqlTicketDBRowsConn);
    SqlDataReader sqlTicketDBRowsReader = sqlTicketDBRowsCmd.ExecuteReader();
    Int16 TicketDBrowcount = 0;
    while (sqlTicketDBRowsReader.Read())
    if (TicketDBrowcount > 0)
    TicketDBRows += ", ";
    TicketDBRows += " " + sqlTicketDBRowsReader.GetString(0) + " ";
    TicketDBrowcount++;
    #endregion
    String Pattern = @"(\D)\s-\s(\d+)(\s-\s(.*)\s-\s(.*))?";
    String ReProcessFile = null;
    if (prodtable.Equals("Template")) {
    ReProcessFile = "E:\\Templates\\Configs\\" + prodtable + "-Reprocess.txt";
    else
    ReProcessFile = "E:\\SSIS_Configs\\" + custName + "\\" + prodtable + "-Reprocess.txt";
    #region Process Re-Process File
    if (File.Exists(ReProcessFile))
    //MessageBox.Show("File is found");
    using (StreamReader sr = new StreamReader(ReProcessFile))
    //MessageBox.Show("File has been opened");
    string line;
    while ((line = sr.ReadLine()) != null)
    //MessageBox.Show("Found a Line: " + line);
    Regex rgx = new Regex(Pattern, RegexOptions.IgnoreCase);
    MatchCollection matches = rgx.Matches(line);
    foreach (Match match in matches)
    GroupCollection groups = match.Groups;
    Reprocess = groups[1].Value;
    ReprocessDate = groups[2].Value;
    ReprocessPrime = groups[4].Value;
    ReprocessVal = groups[5].Value;
    //MessageBox.Show("Variables Set." + Environment.NewLine +
    // "Reprocess: " + Reprocess + Environment.NewLine +
    // "Reprocess Date: " + ReprocessDate + Environment.NewLine +
    // "Reprocess Primary Field: " + ReprocessPrime + Environment.NewLine +
    // "Reprocess Value Field: " + ReprocessVal);
    //MessageBox.Show("End Processing File");
    #endregion
    #region Re-Proccess Rows
    if (Reprocess.Equals("T"))
    if (String.IsNullOrEmpty(ReprocessPrime) && String.IsNullOrEmpty(ReprocessVal))
    else
    //MessageBox.Show("Finished Getting Read Only Variables");
    string sqlQuery = "SELECT TOP (1000) " + uniqIDField + " " +
    "FROM " + prodtable + " " +
    "WHERE " +
    "[" + ReprocessVal + "] IS NULL " +
    "AND " +
    "[" + ReprocessPrime + "] IS NOT NULL " +
    "ORDER BY [" + modField + "]";
    //MessageBox.Show("sqlQuery: " + sqlQuery);
    SqlCommand sqlCmd = new SqlCommand(sqlQuery, sqlConn);
    SqlDataReader sqlReader = sqlCmd.ExecuteReader();
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " WHERE "; // + modField + " > '" + maxModDate + "' ";
    while (sqlReader.Read())
    if (count == 0)
    newSelectSQL += " CASE_ID IN (";
    if (count > 0)
    newSelectSQL += ", ";
    newSelectSQL += "'" + sqlReader.GetString(0) + "'";
    count++;
    newSelectSQL += ") OR " + modField + " > '" + maxModDate + "' ORDER BY " + modField + " ASC";
    //sqlConn.Close();
    if (count == 0)
    //MessageBox.Show("Reprocess: " + Reprocess + Environment.NewLine + "Start Date: " + ReprocessDate);
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " " + "WHERE " + modField + " >= '" + ReprocessDate + "' ";
    newSelectSQL += "ORDER BY " + modField + " ASC";
    vars["User::Reprocess_Records"].Value = newSelectSQL.ToString();
    //Dts.Variables["User::Reprocess_Records"].Value = "T";
    else
    //MessageBox.Show("NO Reprocess: " + Reprocess + Environment.NewLine + "Max Date: " + maxModDate);
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " " + "WHERE " + modField + " > '" + maxModDate + "' ";
    newSelectSQL += "ORDER BY " + modField + " ASC";
    #endregion
    else
    //MessageBox.Show("NO Reprocess: " + Reprocess + Environment.NewLine + "Max Date: " + maxModDate);
    newSelectSQL = "SELECT " + TicketDBRows + " FROM " + TicketDBSchema + "." + tablename + " " + "WHERE " + modField + " > '" + maxModDate + "' ";
    newSelectSQL += "ORDER BY " + modField + " ASC";
    //MessageBox.Show("Maybe New SQL: " + newSelectSQL.ToString());
    //Variables vars = null;
    MessageBox.Show("Got Variable now lets set it to: " + newSelectSQL.ToString());
    // Now you can use the variables
    vars["User::TicketDB_Get_SQL"].Value = newSelectSQL.ToString();
    MessageBox.Show("New SQL: " + vars["User::TicketDB_Get_SQL"].Value.ToString());
    //vars.Unlock();
    catch (Exception ex)
    //MessageBox.Show("Error :(");
    // Throw an exception or add some logging
    //this.Dts.Events.FireInformation(1, "Something Went Wrong", newSelectSQL.ToString(), "", 0, ref fireAgain);
    throw ex;
    //Dts.TaskResult = (int)ScriptResults.Failure;
    finally
    //MessageBox.Show("Trying to UNLock Variable");
    // Release the locks (even if your script task fails)
    vars.Unlock();
    //Dts.Variables["User::TicketDB_Get_SQL"].Value = newSelectSQL;
    //MessageBox.Show("New SQL: " + Dts.Variables["User::TicketDB_Get_SQL"].Value);
    Dts.TaskResult = (int)ScriptResults.Success;
    So that is my code... when I run it, line # 217 shows what the new Variable should be... However when I hit line # 220 it isn't set and if I let it continue I am watching the variables and it isn't getting set.  I am confused... anyone??
    Billy S.

    Hi Billy S,
    Thank you for sharing your solutions and experience here. It will be very beneficial for other community members who have similar questions.
    Thanks,
    Eileen
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here

  • Service to ssis to script task invocation errors

    Hi.  We run 2012 std and were under the impression that if we gac'd our .dll which is called by our pkg's script task, that plumbing a c# .net service to the pkg wouldn't fail in the pkg script taks with the generic "
    Exception has been thrown by the target of an invocation" error.
    The service calls the pkg.  The script task references the strongly named .dll which is gac'd.
    I'm getting the impression that having the script task do anything other than dts namespace related and c# generic commands will fail with that error.  Not just calls to our method.  As an experiment I threw a generic script task into the pkg prior
    to the first script task and tested with and without just a message box command in that script task prior to Dts.TaskResult being set .   I'm not sure if that was a good way to prove my suspicions or not but my c# knowledge is limited.
    I'll go thru the exercise of uninstalling , removing refs, un gac ing, rebuilding .dll, re gac ing, adding refs back, etc etc but have a bad feeling that my results will be the same.  My peers believe that a call to a gac'd .dll from a script task (all
    initiated by a .net service) should work and not get this .net "state" exception where I believe .net is trying to save us from ourselves when it detects an attempt to execute things in an "external" run/name space.. 
    I have verified that my params are being passed correctly to the pkg from the service and mapping to the proper variables.   Those params are used in the .dll call and there were no problems running the pkg stand alone and executing the same script
    task and gac'd .dll with the default variables values. 

    it looks like using this Parse method also works in the "sql environment" when the pkg is run standalone.  I mean without a .net service calling it.
    I looked at the documentation on this method and don't see anything about it being especially useful when switching between environs (sql vs .net).  So it isn't clear to me why MS made both the explicit cast (eg int) and Parse (eg int.Parse) available
    to its customers and allowed (int) to act on ssis var objects like int.Parse when running pkgs standalone.  But not when a service calls the pkg.  And especially in light of the fact that it is c# that is used to code script tasks.
    But I'm happy to have gotten past this and now need to make sure the same approach will be useful when setting one ssis var = to another.

  • 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

  • Error while sending mail using script task in ssis 2008

    Hi,
        i am trying to send mail using ssis 2008 script task.for my requirement i am not able to use send mail task.
    code i have used is
    declared read only variables system::packagename
     Dim PACKAGE As String
            PACKAGE = Dts.Variables("System::PackageName").Value.ToString()
            Dim myHtmlMessage As MailMessage
            Dim mySmtpClient As SmtpClient
            myHtmlMessage = New MailMessage("[email protected]", "[email protected]", "PACKAGE STATUS", PACKAGE + "WAS FAILED")
         mySmtpClient = New SmtpClient("smtp.gmail.com")
            mySmtpClient.Credentials = New NetworkCredential("[email protected]", "mypassword")
            mySmtpClient.EnableSsl = True
            mySmtpClient.Port = 587
            mySmtpClient.Send(myHtmlMessage)
    error i am getting is
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
    can any one tell me where i am going wrong

    also getting error as follows
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

  • 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

  • Script Task Builds Successfully But Still Has Compile Error (SQL 2012)

    This is repost in a way but the problem has not gone away and I really need to find a solution.
    I have some script from SSIS 2008 that uses the ReportExecution2005
    web service to execute SSRS reports and save the results to Excel. There were some initial problems with confusion between Web Service Reference (legacy?) and Service Reference (WCF) but I think that I have that sorted out
    now.
    The remaining problem is that, while the VB script (which I have pasted in from a working SSIS 2008 Script Task) builds/complies without error, I get a compile error when I close the Script Task and it has the dreaded "Red X" in the Control
    Flow. If I attempt to run the package I get a message box saying that there is a compile error.
    How can I identify the problem and fix the error? The script itself has no errors in SSIS 2008.
    R Campbell

    This is the code by the way (see below) as pasted into the Main sub.
    I have added
    http://localhost/reportserver/reportexecution2005.asmx as a Web Service
    Reference (under the  "Advanced" button) not just a Service Reference (WCF).
    I can build the code without error but I get an error, saying that there is compile error, when I close the Script Task.
    ReportExecutionService definitely shows up in Object Explorer, not the
    WCF "equivalent" of ReportExecutionServiceSoapClient.
    I have always had the impression, that when you close a Script Task, a compiler kicks in to auto-generate some internal script. Could it be (as seems likely) that this compiler is picking up errors that "Build" doesn't (when the script is open)?
    I think that there was once an explicit Compile rather than just Build option in the Script editing environment but I can't find it in SQL 2012 Database Tools (nee BIDS).
    Dim objRSExec As New localhost.ReportExecutionService
    Dim objParam0 As New localhost.ParameterValue
    Dim objParam1 As New localhost.ParameterValue
    Dim objParam2 As New localhost.ParameterValu
    Dim objParam3 As New localhost.ParameterValue
    Dim objParam4 As New localhost.ParameterValue
    Dim objParam5 As New localhost.ParameterValue
    Dim objParam6 As New localhost.ParameterValue
    Dim objParams() As localhost.ParameterValue
    Dim objResult() As Byte
    Dim objStream As FileStream
    Dim FileType As String
    Dim FileExtension As String
    Dim FilePath As String
    Dim NumberOfParameters As Integer
    Dim ReportName As String
    Dim TaskSuccess As Boolean = True
    FileType = Dts.Variables("FileType").Value.ToString()
    FileExtension = Dts.Variables("FileExtension").Value.ToString()
    FilePath = Dts.Variables("FilePathNameExt").Value.ToString()
    ReportName = Dts.Variables("ReportPathName").Value.ToString()
    NumberOfParameters = CInt(Dts.Variables("NumberOfParameters").Value) - 1
    ReDim objParams(NumberOfParameters)
    If NumberOfParameters >= 0 Then
    objParam0.Name = Dts.Variables("P0Name").Value.ToString()
    objParam0.Value = Dts.Variables("P0Value").Value.ToString()
    objParams(0) = objParam0
    End If
    If NumberOfParameters >= 1 Then
    objParam1.Name = Dts.Variables("P1Name").Value.ToString()
    objParam1.Value = Dts.Variables("P1Value").Value.ToString()
    objParams(1) = objParam1
    End If
    If NumberOfParameters >= 2 Then
    objParam2.Name = Dts.Variables("P2Name").Value.ToString()
    objParam2.Value = Dts.Variables("P2Value").Value.ToString()
    objParams(2) = objParam2
    End If
    If NumberOfParameters >= 3 Then
    objParam3.Name = Dts.Variables("P3Name").Value.ToString()
    objParam3.Value = Dts.Variables("P3Value").Value.ToString()
    objParams(3) = objParam3
    End If
    If NumberOfParameters >= 4 Then
    objParam4.Name = Dts.Variables("P4Name").Value.ToString()
    objParam4.Value = Dts.Variables("P4Value").Value.ToString()
    objParams(4) = objParam4
    End If
    If NumberOfParameters >= 5 Then
    objParam5.Name = Dts.Variables("P5Name").Value.ToString()
    objParam5.Value = Dts.Variables("P5Value").Value.ToString()
    objParams(5) = objParam5
    End If
    If NumberOfParameters >= 6 Then
    objParam6.Name = Dts.Variables("P6Name").Value.ToString()
    objParam6.Value = Dts.Variables("P6Value").Value.ToString()
    objParams(6) = objParam6
    End If
    Try
    With objRSExec
    .Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
    .Url = "http://localhost/reportserver/reportexecution2005.asmx"
    .LoadReport(ReportName, Nothing)
    .SetExecutionParameters(objParams, "en-us")
    objResult = .Render(FileType, Nothing, FileExtension, Nothing, Nothing, Nothing, Nothing)
    End With
    objStream = File.Create(FilePath, objResult.Length)
    With objStream
    .Write(objResult, 0, objResult.Length)
    .Close()
    End With
    Catch e As Exception
    Dts.Log("ERROR - RSExec - " & e.Message.ToString(), 100, Nothing)
    TaskSuccess = False
    End Try
    If TaskSuccess Then
    Dts.TaskResult = ScriptResults.Success
    Else
    Dts.TaskResult = ScriptResults.Failure
    End If
    R Campbell

  • Getting "Couldnot find Installable ISAM" error in script task in SSIS 2005 when trying to open (.xlsx files) Excel 2007-2010 files using VB script in Visual Studio 2005

    Hi Experts,
    I am trying to open .xlsx file in script task of SSIS 2005. I am using the 32-bit AccessDatabaseEngine driver with the Connection string as "Provider= Microsoft.ACE.OLEDB.12.0; Data Source=xlsx file path; Extended Properties="Excel 12.0 Xml;
    HDR=YES"" in script task.
    When we debug the VB script in Visual Studio 2005 and encounters the statement app.open() it throws the error "Couldn't find installable ISAM".
    My SQL server version is 2005 SP2 DE
    OS is Windows server 2003 EE SP2
    Could anyone please let me know what is the resolution for this error?
    Thanks and Regards,
    Adesh

    Hi Adesh,
    First, make sure the package runs in 32-bit runtime mode (set Run64BitRuntime property to False) because you are using the 32-bit ACE OLE DB Provider. If it is not the case, the issue may occur due to the corrupted drivers or registry keys. You can try to
    reinstall the 2007 Office System Driver: Data Connectivity Components as Arthur suggested.
    Regards,
    Mike Yin
    TechNet Community Support

  • SSIS PACKAGE MIGRATION FROM 2005 to 2008 - Script task/component errors

    HI All,
    We have to migrate ssis packages (about 300) from ssis 2005 to 2008 .
    1. I understand that the major concern is regarding the script component/tasks.
    I searched a lot about this and also consulted with many friends , all of them are aware of this issue but not able to provide what could be the issues and the solution.
    Can some one help me with the common script issues that can happen during migration and the solution for the same.
     2. I do have one more question.
    As per my understanding given in the below link 
    http://blogs.msdn.com/b/mattm/archive/2008/03/21/package-upgrade-wizard.aspx
    there is this part which says ... 
    Once the packages have been chosen, the next page asks you to pick the output location. This can be:
    Same as the source location
    File System
    SSIS Service (Package Store)
    SQL Server 
    Does this mean I can deploy in sql server directly on fly while upgrading ?
    Any help highly appreciated .
    Regards
    Praveen..

    Hi Praveen,
    Question 1: The error may occur if there are duplicate input columns in the Script Task/Component or the current user cannot access the C:\Windows\Temp directory. Except for the link provided by SanBhaumik, you can also refer to the following
    threads:
    http://www.sqlservercentral.com/Forums/Topic811208-148-1.aspx 
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/5c11eb57-59d6-4f81-bfdc-13bd6489a0ac/sql-server-2008-ssis-package-script-component-error?forum=sqlintegrationservices 
    Question 2: We can directly save the package to the File System, SSIS Package Store, or SQL Server by selecting the proper destination during the package upgrade. However, this operation is not equal to the package install operation identically.
    For example, if we have enabled package configurations for a package, the package configurations won’t be upgraded or installed during the package upgrade.
    Regards,
    Mike Yin
    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

  • Getting error message when i am trying to update the excel file using script task in ssis package

    Hi Guys,
    I am getting error message when I am trying to update the excel. Please find the error messages as below
    Error at Update File [Update File]: Failed to compiled scripts contained in the package. Open the package in SSIS Designer and resolve the compilation errors.
    Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Application' is not defined., ScriptMain.vb, 32, 32
    Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Workbook' is not defined., ScriptMain.vb, 33, 25
    Error at Update File [Update File]: The binary code for the script is not found. Please open the script in the designer by clicking Edit Script button and make sure it builds successfully.
    Warning at Update File [Update File]: Found SQL Server Integration Services 2008 Script Task "ST_050fcae972904039b4f0fe59b7528ece" that requires migration!
    and the code that   I am using is
    Dell - Internal Use - Confidential
    ' Microsoft SQL Server Integration Services Script Task
    ' Write scripts using Microsoft Visual Basic
    ' The ScriptMain class is the entry point of the Script Task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports Microsoft.Office.Interop.Excel
    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="",
    Description:="")> _
    <System.CLSCompliantAttribute(False)> _
    Partial
    Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    Enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum
    Public Sub Main()
            Dts.TaskResult = ScriptResults.Success
    'Dim proc As System.Diagnostics.Process
    'kill all instances of excel
    'For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
    ' proc.Kill()
    'Next
    Dim excelnacomm As
    New Microsoft.Office.Interop.Excel.Application
    Dim wbnacomm As Microsoft.Office.Interop.Excel.Workbook
            wbnacomm = excelnacomm.Workbooks.Open("http://test.xlsx")(renamed
    the excel)
            wbnacomm.RefreshAll()
            wbnacomm.Save()
            wbnacomm.Close()
            excelnacomm.Quit()
            Runtime.InteropServices.Marshal.ReleaseComObject(excelnacomm)
    End Sub
    End
    Class
    Please let me know what could be the reason
    Smash126

    Download:
    Microsoft Office 2010: Primary Interop Assemblies Redistributable
    How to: Add or Remove References By Using the Add Reference Dialog Box  /  How to:
    Add and Remove References in Visual Studio (C#)
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • 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

  • Ssis execute process task error: process exit code was 1 while the expected was 0

    Hi Sir,
    in my SSIS Package(2012) i am using Execute Process Task which will call bat file.  bat file is located on UNC Path.i am having  the below script in the batch file.
     del \\servername\foldername\name.txt
     rcmd \\servername D:\name1.bat
     del \\servername\foldername\name2.txt
    xcopy \\servername\foldername\file.txt   \\server\foldername\outfilefolder
    i am getting the below error message:
    ssis execute process task error:  process exit code was 1 while the expected was 0
    i want know at what cases error exit code was 1?
    Thanks for your time.

    Hi prasad.alm,
    The error is generic and can be caused by various factors. Here are some suggestions for your reference:
    Manually run the executable to execute the batch file so that we can check whether the command lines in the batch file are correct or not.
    Check there are no duplicate/existing files in the destination folder.
    Try to run the package in 32-bit or 64-bit runtime mode.
    If the issue occurs when running a job, try to create a CmdExec type job step to call the excutable. If this job also fails, it might be an issue between executable and SQL Server Agent rather than the SSIS package itself.
    If the issue persists, enable logging for the package, and check if we can obtain more detailed error message for further analysis.
    Regards,
    Mike Yin
    TechNet Community Support

  • Error While executing a SSIS package which contains a script task through SQL Server Agent job

    Hi,
    I have a SQL Server 2012 SSIS package with a script task along with other tasks [data flow, execute sql tasks ]. When I manually executed the job through BIDS, its completed successfully. 
    Then I have automated the execution of the package through SQL Server Agent Job. But when I executed the package through SQL Agent job, it runs successfully for all the tasks except script task. When it comes to execute the Script Task, it is getting failed
    with the below error message.
    "Error: 2012-08-29 12:45:14.67
       Code: 0x00000001
       Source: Script Task 
       Description: Exception has been thrown by the target of an invocation.
    End Error
    DTExec: The package execution returned DTSER_FAILURE (1).
    Started:  12:45:10 PM
    Finished: 12:45:14 PM
    Elapsed:  4.353 seconds
    I have installed the SSIS on the 64-bit environment and SSIS service is running. Also I tried to run the job through 32 bit [job option] but I am getting the above error in all cases.
    Any help will be greatly appreaciated !
    Thanks,
    Navin
    - naveen.reddy

    Hi Arthur,
    My script task access the excel files in a network share, refresh them all and save them. When I execute the ETL manually or thru DTEXEC, it is executing successfully. I am facing the issue when I am executing thru SQL Agent Job only. Logging also showing
    the same error.
    "Error: 2012-08-23 12:45:14.67
       Code: 0x00000001
       Source: Script Task 
       Description: Exception has been thrown by the target of an invocation.
    End Error
    DTExec: The package execution returned DTSER_FAILURE (1).
    Started:  12:45:10 PM
    Finished: 12:45:14 PM
    Elapsed:  4.353 seconds
    - naveen.reddy

Maybe you are looking for