Although there are ways to do this in SSIS, I find it much easier and simpler to just import all csv files into a "staging" table with all varchar fields, then use TSQL INSERT/UPDATE/MERGE in a proc to put the contents into the target table(s). This way you can skip the header/footer and process them separately in your TSQL commands.
comma-delimited file with header and trailer rows
Hi everybody,
I have a csv file with the addition of header and trailer rows. Can you please point me to the clearly written blog / tutorial as how to deal with that (or explain the steps for newbie)? I'd like to load data into 3 separate tables.
Thanks in advance.
3 answers
Sort by: Most helpful
-
-
Yitzhak Khabinsky 26,296 Reputation points
2022-06-14T20:29:19.557+00:00 Hi @Anonymous ,
Alternatively, you can use SSIS Script Component as a Source.
You would need to write there some c# code to filter out not need lines from the input .csv file. -
ZoeHui-MSFT 39,671 Reputation points
2022-06-15T02:01:30.65+00:00 Hi @Anonymous ,
Like YitzhakKhabinsky mentioned you could use C# to do that.
A simple tutorial for your reference below.
Import-a-Flat-file-with-Header-and-Detail-Rows-in
Regards,
Zoe
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.