EXCEL FILES
Hi, I have some excel files in folder. i want pull the data into respective table ( here file name and data base table name are same), based on fine name pull the data into table. 1)meta data is diff each time and sheet names also different each time. as per approach is FOR EACH LOOP and execute sql task . INSERT INTO yourtable SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\test\xltest.xls', 'SELECT * FROM [Customers$]') this is code in execute sql task. my problems 1) i selected Fully qualified option in for each loop. this returns like "C:\Documents and Settings\ADMIN\My Documents\Downloads\bcp\filenames.xls" i want fetch the filename like" filenames " from above directory . 2) each time sheet names also diff. how can i identify the sheet name dynamically. Finnaly my query is INSERT INTO ? SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database= ? , 'SELECT * FROM ? ') plz let me know
October 19th, 2010 11:34am

1- you can go to foreach loop editor, and set retrieve file name as name and extension . 2- there are .NET scripting ways to find out sheet names of an excel file, you can use script task to fetch out sheet names array, and then use it in another foreach loop inside main foreach loop to fetch each sheet name and put you rexecute sql task in INNER foreach loop,this link is sample .NET code for fetch sheet names of an excel file: http://www.codeproject.com/KB/aspnet/getsheetnames.aspxhttp://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
October 19th, 2010 11:56am

Hi Vamsi Please be little bit clear about question. Is it like based on the filename do u need load into corresponding table.
October 22nd, 2010 8:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics