Showing posts with label Business Intelligence Development Studio (BIDS). Show all posts
Showing posts with label Business Intelligence Development Studio (BIDS). Show all posts

Tuesday, May 19, 2015

How to Loop through each record in a SSIS in-memory ADO Recordset Table

In this post we describe Step by step How to Loop through each record in a SSIS in-memory ADO Recordset Table  ,  in Sql Server Integration Services.
In this article we create from scratch a small SSIS application which uses the Foreach SSIS item for a loop through all records in a table.
Your table can be a SQL OLE DB table , an Excel , a raw file , an ADO NET table , an XML . The source of it does not matter, since we'll copy its rows inside an in-memory table , and loop over it.
For this example, we'll loop over all records from an OLE DB SQL Table, in order to send emails to all the "Contacts" in the table.
Our pilot SSIS application will show as the following:




How to Loop through each record in a SSIS in-memory ADO Recordset Table 



First , search in the Toolbox for the Data Flow Task item:

How to Loop through each record in a SSIS in-memory ADO Recordset Table 1

Open it for "Edit" , and add an OLE DB Source:


How to Loop through each record in a SSIS in-memory Table


In the "Edit" mode, set a Connection Manager , and add the following SQL Command:

Loop through each record in a SSIS in-memory ADO Recordset Table

As you can see, our command loads all ercords in the Contact table from Adventure Works:


through each record in a SSIS in-memory ADO Recordset Table


Next, add (this is optional) a Derived Column item , for editing the columns, if you need it.
For this example, we don't edit it. Just drop this item in the Data Flow.
Next, append a Recordset Destination item, in order to keep all fetched records in RAM memory.
Your Data Flow Task should now look as this:


How to Loop through each record in a SSIS in-memory ADO Recordset Table 2

At this point, the Recordset Destination will require an Object variable where to keep the records.
Therefore, create a new variable with "Package" scope as follows:


How to Loop through each record in a SSIS in-memory ADO Recordset Table 3


And then, set the  Recordset Destination's  "variable name" to this variable:

How to Loop through each record in a SSIS in-memory ADO Recordset Table 4

And now, select all the columns that you want to be included in the in-memory table:

How to Loop through each record in a SSIS in-memory ADO Recordset Table 5

Take a close look at the ORDER of this columns: this is going to be very important in the next steps.

Now, add a Foreach Loop Container, which will loop through the in-memory Table:


 SSIS in-memory ADO Recordset Table

In every loop iteration , the current record's data will be copied to the correspondent variables, which now we are going to create as follows:

 in-memory ADO Recordset Table

You must respect the types of the columns being copied: NVARCHAR goes to STRING, and so on.

Inside the  Foreach Loop Container, in "Edit" mode, set the Enumeratoor to  "Foreach ADO Enumerator" :


How to Loop through each record

And tell SSIS that you want to loop through the Object variable that you set before:


 SSIS in-memory ADO Recordset Table


Also select the "Rows in the first table" option.

Now, set the variable mappings EXACTLY IN THE ORDER that they were set inside the ADO in memory table:



How to Loop through each record in a Table

That means, the current record value for the column "ContactID" will be copied to the "iContactID" .integer variable, and so on


That's all!!!! 
Now you will use that loop for example to send emails to all the Contacts in the table, setting the required parameters with the values from the loop variables: 


How to Loop through each record in a  in-memory  Table

Hoping this article was useful to you...


      by Carmel Schvartzman


כתב: כרמל שוורצמן

Tuesday, April 21, 2015

How to check SSIS Variables values at debugging runtime

In this tutorial we describe Step by step How to check SSIS Variables values at debugging runtime   in Sql Server Integration Services .
We'll see here in just 5 minutes how to watch SSIS variables values at debugging, distinguishing between those at Foreach Loop Containers and those at Data Flow Tasks , using the following SSIS application:
How to check SSIS Variables values at debugging runtime



How to check SSIS Variables values at debugging runtime


In the snapshot below can be seen the guiding principles of runtime variables checking  at an "Foreach Loop Container" :
check SSIS Variables values at debugging runtime

First, select the SSIS flow item where you want to watch the variables.
Remember that variables have a scope, therefore you must check that that scope includes the selected item.
For this example, we'll start with a Data Flow Task .
Once you decided what flow item to watch, right click the mouse on it, and click the "Edit Breakpoints" menu item:

values at debugging runtime

Then, select the Break condition to stop the runtime . It can be the On PreExecute event, or any of the Events that you see on the snapshot below:


Variables values at debugging runtime


In the case of a Foreach Loop Container, it is advisable that you spot the variables at the beginning of every loop iteration . Therefore select from the checklist the last item:



SSIS Variables values at debugging runtime

You can also set in which cases to stop the flow: always, or only when the breakpoint has been fetched determined times:

How to check   values at debugging


After you have set the breakpoints, debug the application and, when the breakpoint has been hit, open the "Locals" window. In this window you will find all variables in scope:

check SSIS Variables values at debugging runtime

How to check SSIS Variables values at debugging



That's all. We hope that this example will be useful to you.

Happy programming.....

      by Carmel Schvartzman


כתב: כרמל שוורצמן






Monday, April 13, 2015

How to fix the SSIS error : "Parameter name is unrecognized."

In this post we describe Step by step How to fix the SSIS error : "Parameter name is unrecognized."   in Sql Server Integration Services .
We implement here in just 5 minutes the conventions introduced by Microsoft in the MSDN SQL Server 2014 documentation for SSIS : (applies also to SQL 2005-2008) For sampling this fixing we use the following SSIS application:

 How to fix the SSIS error :  Parameter name is unrecognized.


How to fix the SSIS error : "Parameter name is unrecognized."


In the snapshot above it can be seen that there is a runtime error at an "Execute SQL Task" :
 SSIS error :  Parameter name is unrecognized.




As it is sensible to do, we have defined an SQL parameter and named it "ComputerName". Why? Because the default when adding a new parameter is as follows:

Parameter name is unrecognized.

The default parameter name is "NewParameterName". Therefore, in our example , we have customized it to "ComputerName". And, consequently, we use it in our SQL query as "@ComputerName".
However , we receive the following error : "Parameter name is unrecognized." :


  fix  SSIS error :  Parameter name is unrecognized.



According to MSDN Documentation, while using SQL the parameters must be named as follows:






Therefore we must change our SQL query to complain to those directives, and use the "?" marker :

 How to fix the SSIS error :  Parameter name is unrecognized. 1


Now, the parameters must be mapped to the query, indexed on base "0" .
In our example, we have 4 "?" markers: therefore we add 4 parameters indexed from "0" to "3" :

SELECT  
CAST(
CASE
      WHEN ?  - ? <= 0  
         THEN 0
      WHEN ?  - ? > 0   
         THEN   1
     
      ELSE -1
      END
      
AS FLOAT
)

AS  RESULT

 How to fix the SSIS error :  Parameter name is unrecognized.   2


We hope this example will be useful to you.

Happy programming.....

      by Carmel Schvartzman


כתב: כרמל שוורצמן

Tuesday, November 18, 2014

How to install Business Intelligence Development Studio (BIDS) for Visual Studio 2012 Sql Server 2008


  1. In this article  we will see  How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 
  2. The Business Intelligence Development Studio (BIDS) is an upgrade to Visual Studio 2012 and Sql Server 2008, which includes the SSIS - Sql Server Integration Services templates for creating SSIS applications    :

    SSIS - Sql Server Integration Services

How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 Sql Server 2008



  1. Go to the Microsoft Download Center and get the Visual Studio 2012 templates for the BIDS :

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008
  2. Download and run it as administrator:

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 1
  3. Follow the installation instructions :

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 2
  4. Check that the Business Intelligence for Visual Studio 2012 box is enabled  :

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 3
  5. Continue with the installation :

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 4
  6. Check that everything has been successful :

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 5

     
  7. Now let's see the changes made to Visual Studio 2012 . Before the upgrade, Visual Studio 2012 templates for new projects were like this :

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 6
  8. Now, after the setup, the Visual Studio 2012 templates include also the Business Intelligence ones:

    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 7
  9. Now you can develop SSIS - Sql Server Integration Services projects using the Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 :


    How to install Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 8
  10. In this article we've seen how to install the Business Intelligence Development Studio (BIDS) on Visual Studio 2012 and Sql Server 2008 .
  11. That's all...

    by Carmel Schvartzman

    כתב: כרמל שוורצמן