Dynamic read the csv file through SSIS
Hi,
i want to read the csv file and load data into table
i have two file index file index.csv which indicate location of the filed (this file is change for each application)
second file data.csv which contain actual data for the field
my problem is maping between the table and data.csv file field as i am not able to fix possiton due index file is changes
May 12th, 2012 9:15am
1- you have to import the data to a staging table tblTemp
2- open the Index file and read the fields and save it in another table tblFields
3- you must have a mapping script or table to map the final destination table tblDes with tblTmp
4- use a SP (SQL stored procedure) to map the fields from the tblTemp to tblDes (make a adhoc queries)
DECLARE @str VarChar(3000) = ''
@str = @str + 'INSERT INTO tblDes ( FName, LName .........) '
@str = @str + 'SELECT '
---- the @strMapFields was made before that is provided from the Index file and looks like 'f2 , f5 , f6, f1 ......
@str = @str +@ strMapFields
@str = @str + 'FROM tblTemp '
Exec sp_executesql @str
good luck
Sincerely SH -- MCITP , MCTS -- Please kindly mark the post(s) that answered your question and/or vote for the post(s).
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2012 10:22am


