You can read out the metadata of the table from INFORMATION_SCHEMA.COLUMNS.
The columns in the flat file have to have the same names though.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP