Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine row count in SSIS dataset

Tags:

ssis

ado

I frequently encounter a situation in SSIS packages where I run a SQL Command to return a set of rows from an ADO connection. There are cases where I want to branch based on the number of rows returned. The ado resultset is stored in an SSIS 'object' datatype. Is there a way in SSIS expression or Script component to get that count of rows?

like image 845
JSacksteder Avatar asked Feb 22 '10 15:02

JSacksteder


People also ask

How do you count the number of rows in a dataset?

Use the COUNT aggregate function to count the number of rows in a table. This function takes the name of the column as its argument (e.g., id ) and returns the number of rows for this particular column in the table (e.g., 5).

How does row count work SSIS?

The Row Count transformation counts rows as they pass through a data flow and stores the final count in a variable. A SQL Server Integration Services package can use row counts to update the variables used in scripts, expressions, and property expressions.

How do I find RowCount in SQL?

The SQL COUNT() function returns the number of rows in a table satisfying the criteria specified in the WHERE clause. It sets the number of rows or non NULL column values. COUNT() returns 0 if there were no matching rows.


1 Answers

Instead of using the Execute Sql task, use a dataflow task like this.

  1. Use a source component to retrieve your data
  2. Use a rowcount component to store your rowcount into a variable
  3. Use a recordset destination component and store that in your original variable (system.object type)

Then return to the control flow and continue as you planned, using the rowcount variable to branch your control flow.

like image 61
William Salzman Avatar answered Sep 22 '22 09:09

William Salzman