I have the below within the Data-flow area. The problem I'm experiencing is that even if the result is 0, it is still creating the file.
Can anyone see what I'm doing wrong here?
This is pretty much expected and known annoying behavior. SSIS will create an empty flat file, even if unchecked: "column names in a first data row".
The workarounds are:
remove such file by a file system task if @RowCountWriteOff = 0
just after the execution of a dataflow.
as alternative, do not start a dataflow if expected number of rows in the source is 0:
Update 2019-02-11:
Issue I have is that I have 13 of these export to csv commands in the data flow and they are costly queries
OnPostExecute
event handler, so cleanup logic is isolated to some certain dataflow:Based on your comment i will assume that you want to loop over many tables using SQL Commands, check if table contains row, if so then you should export rows to flat files, else you should ignore the tables. I will mention the steps that you need to achieve that and provide links that contains more details for each step.
Execute SQL Task
with a count command SELECT COunt(*) FROM ....)
and store the Resultset inside a variable
@[User::RowCount] > 0
Also, it is good to check the links i provided because they contains a lot of useful informations and step by step guides.
Preventing SSIS from creating empty flat files is a common issue that you can find a lot of references online, there are many workarounds suggested and many methods that may solves the issue:
Data Flow Task
Delay Validation
property to True
Data Flow Task
within the package, which will be used only to count rows in the Source, if it is bigger than 0
then the precedence constraint should led to the other Data Flow Task
File System Task
after the Data Flow Task
which delete the output file if RowCount is o
, you should set the precedence constraint expression to ensure that.Data Flow Task
Delay Validation
property to True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With