Question

I am creating an SSIS package that will write in the header of a text file

STARTDATE|ENDDATE|ROWCOUNT

followed by the results of a stored procedure. ROWCOUNT is the number of rows in the data set from the stored procedure. The data set is written to the body of the flat file.

My package is successful. It has three data flow tasks:
DetermineRowCount, WriteHeader, and WriteData.

DetermineRowCount and WriteData both hit a copy of the same OLE DB Source - Data item.

DetermineRowCount data flow is OLE DB Source - Data ---> Row Count where the RowCount variable is set.

I would like to eliminate one copy of the OLE DB Source - Data.

Is there a way to obtain the RowCount and the data, write the header, then write the body, without calling the stored procedure twice?

Was it helpful?

Solution

The short answer to the question "Is there a way to obtain the RowCount and the data, write the header, then write the body, without calling the stored procedure twice?" is, alas, "No." At least, not in a single data flow.

However, it is possible to eliminate the second call to the stored procedure. Add a Row Count transformation to the original data flow and save the count to an appropriately named variable. Then add a Script Component to the package flow to prepend the desired header row to the text file.

OTHER TIPS

You can write the header and the body in the same data flow. Just put the RowCount component in there, right after the source component.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top