Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Data Warehousing
»
Integration Services
»
data from flat file
data from flat file
Rate Topic
Display Mode
Topic Options
Author
Message
Confusing Queries
Confusing Queries
Posted Monday, April 30, 2012 4:51 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Sunday, July 29, 2012 2:10 PM
Points: 197,
Visits: 437
I am trying to load a flat file using SSIS. The data in the flat file is something like this
id, name, status
1, Jassy,
2,, abcd
3, v'dejr, dkfal'sdfh
when I loaded then to the SQL Server, I am getting blank spots on the places where there is no data.
1 Jassy
2 abcd
3 v'dejr dkfal'sdfh
I want null instead, what could be done in the downstream to get it done. There are 28 columns in the actual file and I am trying to avoid update query after I load data.
Thanks
Post Attachments
Capture.PNG
(
6 views,
2.82 KB
)
Post #1292873
Evil Kraig F
Evil Kraig F
Posted Monday, April 30, 2012 5:30 PM
SSCertifiable
Group: General Forum Members
Last Login: Saturday, May 18, 2013 10:09 PM
Points: 5,658,
Visits: 6,100
Use a derived column that will check for blank spaces and insert the null version of the datatype into the column if that happens.
Basically, for each column, you'll do something like this as the expression (assuming it's an INT):
LTRIM(RTRIM( Column1)) == "" ? NULL(DT_UI4) : Column1
Use that as a replace columna and it'll include NULLs into the stream. For the source file to actually recognize NULL, they'd have to use the particular ANSI character that is considered it (I forget offhand) which is an unreadable character.
- Craig Farrell
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions
|
Forum Netiquette
For index/tuning help, follow these directions.
|
Tally Tables
Twitter: @AnyWayDBA
Post #1292880
robert.gerald.taylor
robert.gerald.taylor
Posted Wednesday, May 02, 2012 12:14 PM
Right there with Babe
Group: General Forum Members
Last Login: Today @ 11:10 AM
Points: 740,
Visits: 785
Evil Kraig F (4/30/2012)
Basically, for each column, you'll do something like this as the expression (assuming it's an INT):
LTRIM(RTRIM( Column1)) == "" ? NULL(DT_UI4) : Column1
What Evil Kraig says is spot on; one little nitpick, SSIS expressions has a TRIM() function that you can use to replace the LTRIM(RTRIM()). Something like:
TRIM(Column1)) == "" ? NULL(DT_UI4) : Column1
Post #1294093
Daniel Bowlin
Daniel Bowlin
Posted Thursday, May 03, 2012 7:32 AM
SSCrazy
Group: General Forum Members
Last Login: Today @ 8:49 AM
Points: 2,672,
Visits: 2,417
One other thing you can look at, althought I have not tested it for this purpose. In the flat file source editor on the connection manager tab there is a checkbox for "Retain null values from the source as null values in the data flow."
Post #1294594
sqlbi.vvamsi
sqlbi.vvamsi
Posted Friday, May 11, 2012 9:51 AM
SSC Rookie
Group: General Forum Members
Last Login: Yesterday @ 10:11 AM
Points: 48,
Visits: 269
That idea by Dan should work.
Post #1298721
mohit_3454
mohit_3454
Posted Wednesday, June 06, 2012 5:14 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 7:10 AM
Points: 15,
Visits: 53
I agree.. Use "Retain null values from the source as null values in the data flow" in flat file connection manager.
Post #1311753
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.