|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 11:35 AM
Points: 4,
Visits: 153
|
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 5:01 AM
Points: 4,815,
Visits: 1,343
|
|
Useful one. Good for the new bies in SSIS. Also the links provided at the end are useful. :)
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 31, 2010 7:40 AM
Points: 1,
Visits: 14
|
|
Hi,
This is an old problem with importing Excel, we just put in a dummy first row with data in the form rewuired for each column, e.g. TEXT for text, 1234 for number, etc. , then delete the first record imported. tends to solve the problem for us.
Pete Wiggins
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Tuesday, March 12, 2013 1:26 PM
Points: 86,
Visits: 473
|
|
One could just save the Excel as a CSV file, load the file via BULK INSERT or OPENROWSET and be done.
Why go through hoops on and develop SSIS package? The portability and predictability of SSIS isn't that great anyway.
my 2 cents...
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Wednesday, January 02, 2013 12:15 PM
Points: 1,443,
Visits: 711
|
|
I've had a similar problem - ended up resolving the problem as follows:
1) save the data as csv 2) create the table with the correct datatypes before importing.
That worked for me, and was alot simpler; although I believe your solution does help demonstrate some of the capabilties of SSIS.
Mark
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, November 21, 2012 9:52 AM
Points: 10,
Visits: 61
|
|
Much easier way is:
Load the Excel file with First Row as Header off even it contains the header. This can ensure all the fields are read in text format. And then add a Conditional Split to skip the first row.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 1:41 PM
Points: 10,613,
Visits: 11,952
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 30, 2013 6:41 AM
Points: 1,110,
Visits: 1,146
|
|
| I may be missing something, but couldn't you just modify the select clause on the spreadsheet and manually cast to the correct datatype?
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, August 22, 2011 1:46 PM
Points: 16,
Visits: 114
|
|
| Call me crazy, but I think I would do a global change on the column to eliminate the dash.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, March 18, 2013 7:04 PM
Points: 4,
Visits: 107
|
|
I found an easier way using steps in this MS KB article on the very same subject. I tried it and it works very well.
Solution : Set ConnectionString property of Excel source file as following
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=filepath\filename.xls;Extended Properties=”EXCEL 8.0;HDR=YES;IMEX=1“;
NOTE: Setting IMEX=1 tells the driver to use Import mode. In this state, the registry setting ImportMixedTypes=Text will be noticed. This forces mixed data to be converted to text. For this to work reliably, you may also have to modify the registry setting, TypeGuessRows=8. The ISAM driver by default looks at the first eight rows and from that sampling determines the datatype. If this eight row sampling is all numeric, then setting IMEX=1 will not convert the default datatype to Text; it will remain numeric.
You must be careful that IMEX=1 not be used indiscriminately. This is IMPORT mode, so the results may be unpredictable if you try to do appends or updates of data in this mode.
Reference : http://support.microsoft.com/kb/194124/en-us
|
|
|
|