blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

SSIS Junkie

SSIS Nugget: Output the rowcount

I haven't published a nugget for a while but today a guy called Antonio was asking me how one might output the captured rowcount in a file so i thought I'd put something together that demonstrated it.

Its very simple, although you will need two data-flows. One to capture the rowcount (using a rowcount component), and another to output that captured value.

Here's the first data-flow that contains the rowcount component

and the second that outputs the value:

 

The trick is being able to put the captured value into the data-flow and you do that using the Derived Column component. Within the Derived Column Component your expression simply has to contain the name of the variable into which you earlier captured the rowcount.

 

Following your putting the value into the data pipeline you simply output it using a flat file destination adapter.

That really is all there is to it. Hope you find it useful Antonio!

You can download the demo package from here: http://blogs.conchango.com/jamiethomson/attachment/6164.ashx. One caveat - it runs against the sample AdventureWorks database (its got to count some rows from somewhere right?) so you will need to have that installed. The package will look for this database on the localhost server.

-Jamie

 

Published 28 February 2007 06:23 by jamie.thomson
Attachment(s): OutputRowcount.zip

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Antonio said:

Thank you Jamie,

yesterday I found a similar solution but using as input source in the second data flow a OLE DB Source with the following script:

SELECT 'CICCIOPASTICCIO' CICCIO

And then adding Derived Columns using the counting variables previously filled in.

But I think that for doing a very simple operation we have to follow an excessive long way that seems a workaround...

Thanks again

Antonio

February 28, 2007 09:04
 

Darren said:

Well it is a pure solution I'll give you that, but the secind DFT is a bit of a pain. I think a Script Task might be cleaner, although it means a bit of code to open the file, read the variable value and write it to your file.

If you want this for logging purposes then the Row Count Plus tranform I wrote will raise the count as a event which means you can feed it through standard SSIS logging. Depends on the requirements I guess.

March 2, 2007 16:41
 

jamie.thomson said:

Indeed. but the guy wanted to achieve it without writing code.

Good point about your transform. i forgot about that to be honest.

-Jamie

March 2, 2007 16:48
 

Isondart said:

Interesting. I searched for this particular article in an attempt to log the number of rows that existed in an excel file. Basically, the row count transform editor captured the variable and the execute sql task needed an additional parameter set to NUMERIC in order to capture and log the row count information into a sql table.

July 7, 2008 18:35

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

Powered by Community Server (Personal Edition), by Telligent Systems