CSharped
CSharped

Reputation: 1287

SSIS OLE DB datasource Check row count

I have an SSIS package with a OLE DB source reading two columns from a table. I need to check if the source table has some records and perform different actions based on whether the row count from source table is 0 or not.

Upvotes: 0

Views: 3363

Answers (2)

Swamy
Swamy

Reputation: 11

You need to use Execute SQL Task and in that you can count the number of records and assign it to a variable.

Then , you can use "Precedance Constraint Editor" and give the formula as "@[User::RecordCount]>1" do some other task.

Hope I answered your query.

Upvotes: 1

criticalfix
criticalfix

Reputation: 2870

The OLE DB Source is in a Data Flow Task which handles one record at a time. If you want to ask a question about the table as a whole, you should do that in the Control Flow, not in the Data Flow.

Create an Execute SQL task in your control flow and use it to, for instance, count the number of records in a table, or the number of records that match a certain condition. Then you can take other actions based on the parameters and return codes.

If you want to do Task A if your table has zero record, but Task B if it has more than zero records, then look at adding expressions to the precedence constraints leading to Task A and Task B.

Upvotes: 1

Related Questions