March 27, 2009 at 9:11 am
I was having some trouble modifying a string column of a CSV file when it had no value before it was inserted into an int field of an SQL Server 2005 table.
I initially tried by using a Derived Column with Replace(Age,"","0) which didn't work. Using Data Viewers before and after the Derived Column I could see that the value was never changing (empty in both cases).
I got around this by setting the Flat File Source to retain null values and then modifying my Derived Column to use ISNULL(Age)?"0":Age.
Just out of curiosity, how should I have originally gone about it without setting the Flat File Source to retain null values? What was wrong with my Replace command? How do I refer to an empty value in a CSV file?
March 27, 2009 at 9:45 am
I would say that retaining the nulls is the correct handling in this case. That's what the feature is for.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
March 30, 2009 at 6:09 am
I would agree with GSquared. Especially in this case because an empty value for age does not equate to an age of 0 so Null would be, in my opinion, the best option.
Jack Corbett
Consultant - Straight Path Solutions
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
March 30, 2009 at 6:11 am
Thanks for the help guys, I appreciate it. I'll stick with the null value method.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply