I have a SQL table which holds below details. Invoice Id and their respective details. Each Invoice can have single or multiple lines.
My requirement is I need to split multiple CSV files. I can do that easily using SSIS.
But the catch is supposed an invoice has 4 lines, then it should be captured in single file. Not 2 lines in one file and another two lines in another file. This has to be handled while exporting in SSIS
For example, the given data has 20 records so ideally if I am splitting to 10 records each, then 2 files would be extracted. But if you see in the 8th-row invoice 105 has 4 lines. Hence it should move to 2nd file. And the 1st file will have till Invoice 104 which comes to 8 rows(which is fine). This seems a very tricky task for me. I would appreciate any inputs on how to achieve this.

select MAX(InvoiceID) / 2 from YourTableto work out a data range, then export the records to two files, but is two files what you want? four files? you need to clarify. - Nick.McDermaid