Professional SQL Server™ 2005 Integration Services
by Brian Knight, Allan Mitchell, Darren Green, Douglas Hinson, Kathi Kellenberger, Andy Leonard, Erik Veerman, Jason Gerard, Haidong Ji, Mike Murphy
6.5. Row Count
The Row Count transformation task provides the ability to count rows in a stream that is directed to its input source. This transformation must place that count into a variable. This transformation is useful for tasks that require knowing "How many?" It is especially valuable since you don't physically have to commit stream data to a physical table to retrieve the count. If you need to know how many rows are split during the Conditional Split transformation, direct the output of each side of the split to a separate Row Count transformation. Each Row Count transformation is designed for an input stream and will output a row count into a Long or compatible data type. You can then use this variable to log information into storage, to build e-mail messages, or to conditionally run steps in your packages.
This transformation uses the Advanced Editor. As you recall, you used this editor in the Import Columns section of this chapter. Configuring this transformation is much easier. All you really need to provide in terms of configuration is the name of the variable to store the count of the input stream.
You will now simulate a situation where you have a conditional step in a package that should run only if an input stream row count is evaluated to have a row count greater than zero. You could use this type of logic to implement conditional execution of any task, but for simplicity, you'll conditionally execute a SQL Statement.
Create an SSIS package named Row Count Example. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access