September 18, 2006 at 3:58 am
Friendz,
I need to build an SP which will import data from excel files to the system. We've 15-20 excel files which has 25000+ records.
I just want to know what/which is the best way to accomplish the task?
--Ramesh
September 18, 2006 at 7:01 am
You can use
SELECT * FROM
OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;HDR=YES;Database=C:\temp\book1.xls', [sheet1$])
and use dynamic sql to substitute the workbook name
but beware that when SQL reads Excel files is uses the first few rows (using a value in the registry) to determine what the column data type is and will return null if any data does not match the datatype chosen
There are some MS articles (as well as a few on this site) that describe ways to try to overcome this but I have never got it to work correctly
Far away is close at hand in the images of elsewhere.
Anon.
September 19, 2006 at 6:58 am
Using the IMEX=1 option overcomes the problem (if it is a problem) of SQL Server engine trying to determine data type and size. It can lead to real problems if a column has mixed numbers and alpha characters or null values. Also, if the column contains a large amount of text that is not represented in the first 8 rows. See excerpt from MSDN:
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply