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 Tuesday, June 16, 2009 10:10 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 30, 2014 10:14 AM
Points: 9, Visits: 21
Another way is to add a "Derived Column Transform" and use the expression "?" with a default value that replaces null.

Example: ISNULL([testColumn])?0:[testColumn]

Raj
Post #735820
Posted Wednesday, October 21, 2009 3:32 PM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, March 18, 2014 2:14 PM
Points: 614, Visits: 89
How about this simple solution:

http://blog.tylerholmes.com/2007/12/walkthrough-connecting-to-excel-2007.html


:P
Post #806847
Posted Wednesday, October 21, 2009 4:04 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 4:38 PM
Points: 846, Visits: 1,325
Raj,
If you add that expression, you will indeed not have a NULL in the column, but that doesn't help the case where there was actual data in the column that was lost because the JET driver looked at the column and treated it as a FLOAT instead of a CHAR(255). The best example I have for this is Zip+4 codes mixed with Zip codes in a single column. Excel will read the column, see that the majority are FLOAT and will treat anything with a hyphen as a NULL for purposes of import because it's not a FLOAT. That defeats the purpose.

JW,
That solution looks okay, but as one person commenting on it noted, it forces everything to a char(255) and you lose any Memo data that might have been stored. If one of your columns is > 255 characters, you lose the data. You also then have to deal with everything that is now being treated as a char(255) and any odd conversions that happen as a result. That in itself shouldn't be too bad, but it is a pain. It's also kind of frustrating because you can't set that option when using the Wizard. You need to code for it. :P


As noted in one of my earlier posts, I deal with this when receiving files from customers that have multiple sheets (making it impractical to try to export and choose a good delimiter), a mixture of data-types, and usually with some Note/Memo data. That leaves me with a lot of pain points when trying to load data directly from Excel. And there are a lot of workarounds, but hopefully people will be aware that there are definitely some areas to watch for when importing Excel using SSIS.



Post #806858
Posted Wednesday, October 21, 2009 4:11 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 4:04 PM
Points: 204, Visits: 469
I found the answer - use a conditional split - work out which column can never be null for a valid row, divert all of the rows that do NOT fit that condition in to the remainder of the data flow

Easy....innit....dunno why it stumped me for so long!
Post #806861
Posted Tuesday, January 5, 2010 3:24 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 20, 2011 12:23 AM
Points: 5, Visits: 27
I'm having a similar problem to this but it is localised to my machine only. My colleague wrote a package to import an Excel spreadsheet in SQL Server. It works perfectly on his machine but when we transferred the package/solution in its entirety to my machine, the behaviour described in this forum appeared on mine. Does anyone have any ideas why this might be the case. We have the same software version and all drivers on both our computers are the same.
Post #842464
Posted Tuesday, January 5, 2010 3:40 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 4:38 PM
Points: 846, Visits: 1,325
Perhaps he has the registry settings for IMEX or similar set differently on his machine? If you can be more specific with the issues, that might help some. My best guess is that your colleague's registry settings are different than yours.


Post #842474
Posted Tuesday, January 5, 2010 4:23 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 20, 2011 12:23 AM
Points: 5, Visits: 27
First of all, regarding registry settings, noone in our office can edit registry settings, at least through regedit as it has been disabled for use across the organisation.

As far as more information:

The column I refer to has dates in. There are around 1000 rows of data. The first three rows in the particular column are empty. Then there are a few dates and the pattern sort of repeats itself like that. When the data is previewed in SSIS, the first three rows show as empty for that column but every row with a valid date in shows as "NULL".
Post #842492
Posted Tuesday, January 5, 2010 4:39 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 4:04 PM
Points: 204, Visits: 469
Use a derived column to convert the datestring to the format yyyy-mm-dd
RIGHT(thedate,4) + "-" + SUBSTRING(thedate,4,2) + "-" + SUBSTRING(thedate,1,2)

as a unicode string (DT_WSTR) then convert that (data conversion) do a date (dt_date). This is what works for me.
Post #842494
Posted Tuesday, January 5, 2010 4:57 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 4:38 PM
Points: 846, Visits: 1,325
Sounds very much like the registry settings may have been edited - perhaps with a support ticket or similar. That sounds suspiciously like the option to read all rows in a column to determine its type. Otherwise, your package could be treating that column as just about any other type and running into issues w/ conversion.

I assume that you've verified for all of the non-NULL columns that the data contains a valid date and not something that's almost a date. Is it possible that it's trying to read in some slightly different format for the date and choking on that? Perhaps trying to read dd-mm-yyyy instead of mm-dd-yyyy or yyyymmdd?

Without knowing too much more about the file(s), is it also possible that the files that have run successfully have had fully populated date columns? I know that once you release a spec into the wild you don't really know what you'll get back.



Post #842501
Posted Friday, August 19, 2011 4:50 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 9:47 PM
Points: 3, Visits: 115
Thanks thejackfy Great workaround!
Post #1162361
« Prev Topic | Next Topic »

Add to briefcase «««12345»»

Permissions Expand / Collapse