0
CREATE TABLE Items
(
Product varchar(10),
Customer varchar(10),
Store varchar(10)
)

Question 1: I have to use SSIS and generate a file items.txt in the below format from the above table. The first line is a hardcode value "Header|Items" and the trailer is Trailer|Recordcount:" + records count.

Question 2: I have to use SSIS to read the items.txt file in the below format and load only detail records to the above Items table.

Line 1 : Header|Items

Line 2 : ProductData1|CustomerData1|StoreData1

Line 3 : ProductData2|CustomerData2|StoreData2

Line 4 : Trailer|Recordcount:2

I have to use the same file format mentioned in the above example no alteration of file format is allowed.

Kumar
  • 57
  • 1
  • 1
  • 5
  • I'd recommend c# for this task since you need an extra header and footer. Load into a reader. loop thru reader, if row 1 then add header, write details out, if row = reader.Length then write out trailer. – KeithL May 26 '21 at 11:54
  • Probably you can use something like the following answer https://stackoverflow.com/a/42650819/1008588 – Nicolaesse May 26 '21 at 12:21
  • @Nicolaesse does your solution work if we have a different number of columns in Header(1) Detail(2) and Trailer(2). I mean I don't care about the Header and footer schema just will load the detail records to a table. – Kumar May 26 '21 at 14:22

0 Answers0