Hello thunderlights880,
Thank you for the post.
It is possible to do it - here is an idea to get you started with:
- add "Set variable" activity
- add variable "FileRow" of type integer and value 0
- add variable "FileRowCount" of type integer and value 0
- add "Execute script" activity
- (Now we will create two tables - one that contains all the data and second that will be filled later with always 250k rows of data extracted from the first table)
- DROP TABLE if exists myTempTable ---- the "if existst" part differs among providers.. this should work in MySQL for example
- CREATE TABLE myTempTable (id with primary key.., then your columns here)
- INSERT INTO myTempTable SELECT <your_large_data>) (let's say we have 2.000.000 rows (so 8 excel fiels if one should be per 250.000)
- DROP TABLE if exists myTempTableOut
- CREATE TABLE myTempTableOut (id with primary key.., then your columns here)
- add "While..." activity (for loop)
- the condition would be #FileRow# == 0 or #FileRowCount# > 0
- add "Set variable value" activity into the while branch
- increment the variable FileRow by 1 (i.e. every new loop iteration will increase the file row variable)
- add "Execute script" activity into the While branch
- change the row count variable name to "FileRowCount" (originally it's something like Execute_1_RCOUNT)
- TRUNCATE TABLE myTempTableOut
- INSERT INTO myTempTableOut SELECT TOP 250000 * FROM myTempTable
- DELETE FROM myTempTable WHERE id in (SELECT DISTINCT id from myTempTableOut)
- SELECT id from myTempTableOut
- add "Log comment" activity into the while branch
- this will be just for diagnostics
- add text "file row: #FileRow#, output row count: #FileRowCount#"
- you need to ensure that it will give you the exact row count that is currently present inside the myTempTableOut.. (the last select statement ensures to fill the variable)
- add "Select to file" activity into the while branch
- SELECT * FROM myTempTableOut
- specify output type Excel and for the file path use "myOutputFile_#FileRow#"
- the above step ensures that each new file generated will get _1 _2 _3 etc. in the ending
- add "Archive" activity at the end of the script
- zip all files that match the pattern myOutputFile_*.xlsx
- add "Send email" activity at the end of the script
- attach the zipped archive file
Hope it makes sense (i didn't test it, i only wrote it from my head)
Martin