Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

How to Handle NULL Values Loaded by SSIS from Excel Files Expand / Collapse
Author
Message
Posted Sunday, April 27, 2008 8:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 13, 2014 9:08 AM
Points: 4, Visits: 160
Comments posted to this topic are about the item How to Handle NULL Values Loaded by SSIS from Excel Files
Post #491125
Posted Monday, April 28, 2008 12:09 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, August 14, 2014 12:26 AM
Points: 5,335, Visits: 1,383
Useful one. Good for the new bies in SSIS. Also the links provided at the end are useful. :)


Post #491196
Posted Monday, April 28, 2008 3:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 11:23 AM
Points: 1, Visits: 16
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
Post #491267
Posted Monday, April 28, 2008 5:49 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, May 5, 2014 8:55 AM
Points: 86, Visits: 478
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...
Post #491299
Posted Monday, April 28, 2008 6:03 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, January 2, 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
Post #491310
Posted Monday, April 28, 2008 6:12 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, June 19, 2014 10:18 AM
Points: 10, Visits: 73
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.
Post #491318
Posted Monday, April 28, 2008 6:58 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:01 AM
Points: 11,216, Visits: 12,973
I thought the article was well-written and easy to follow. I do agree with others that loading the first row (header) as data in the source would be the simplest solution, yet I understand why you would miss this initially.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #491345
Posted Monday, April 28, 2008 7:08 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, October 23, 2013 7:57 AM
Points: 1,110, Visits: 1,148
I may be missing something, but couldn't you just modify the select clause on the spreadsheet and manually cast to the correct datatype?
Post #491357
Posted Monday, April 28, 2008 7:37 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

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.
Post #491381
Posted Monday, April 28, 2008 7:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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

Post #491383
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse