SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Problem with data conversion


Problem with data conversion

Author
Message
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)

Group: General Forum Members
Points: 43541 Visits: 19862
I'm trying to import a flat file into a table in my SQL Server database. However, the derived column transformation is giving an error but only on certain columns and certain rows, but we can't find out why.

The data in the file is as showed below.

4762040400085003 000539021910000541161240001074615170000870464640000579997880001019609700000626533310001411425950001035889150001011675240000930959670001031754130
4762040400093338 00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p
4762040400094930 000214147680001095445120000462680660000812678980000872152370000580503800000626533310001411425950001035889150001011675240000930959670001031754130

The rows are divided into one column of 19 chars and 12 of 12 chars. Each of the 12 chars columns represents a decimal and if it ends on p it should be negative.
The first 2 lines are converted successfully but the 3rd line throws an error on Columns 3, 9, 10, 11 & 13 and returns NULL values.
The code used to transform the columns is the following.
SUBSTRING([Column 2],12,1) == "p" ? (DT_NUMERIC,12,3)SUBSTRING([Column 2],1,11) * @[User::Negative] : (DT_NUMERIC,12,3)SUBSTRING([Column 2],1,12) * @[User:Tongueositive]


Do you have any idea on what's happening? Should I use something different for this instead of the derived column?

If more info is needed, please tell me.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)

Group: General Forum Members
Points: 65232 Visits: 13298
What's the error?
At first sight nothing is wrong with the expression.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)

Group: General Forum Members
Points: 43541 Visits: 19862
Hi Koen,
The expression works on most cases but on some values it just returns NULLS when it ignores failures or the following errors that make the task fail.


[Derived Column [187]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The "component "Derived Column" (187)" failed because error code 0xC0049063 occurred,
and the error row disposition on "output column "Derived Column 3" (250)"
specifies failure on error. An error occurred on the specified object of the specified component.
There may be error messages posted before this with more information about the failure.

[Derived Column [187]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The "component "Derived Column" (187)" failed because error code 0xC0049063 occurred, and the error row disposition
on "output column "Derived Column 3" (250)" specifies failure on error.
An error occurred on the specified object of the specified component.
There may be error messages posted before this with more information about the failure.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED.

The ProcessInput method on component "Derived Column" (187) failed
with error code 0xC0209029 while processing input "Derived Column Input" (188).
The identified component returned an error from the ProcessInput method. The error is specific
to the component, but the error is fatal and will cause the Data Flow task to stop running.
There may be error messages posted before this with more information about the failure.


[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED.
The ProcessInput method on component "Derived Column" (187) failed with error code 0xC0209029
while processing input "Derived Column Input" (188). The identified component returned an error
from the ProcessInput method. The error is specific to the component, but the error is fatal
and will cause the Data Flow task to stop running. There may be error messages posted before this
with more information about the failure.


I'm uncertain on what could be wrong.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)SSC Guru (223K reputation)

Group: General Forum Members
Points: 223777 Visits: 42007
Luis Cazares (8/28/2013)
I'm trying to import a flat file into a table in my SQL Server database. However, the derived column transformation is giving an error but only on certain columns and certain rows, but we can't find out why.

The data in the file is as showed below.

4762040400085003 000539021910000541161240001074615170000870464640000579997880001019609700000626533310001411425950001035889150001011675240000930959670001031754130
4762040400093338 00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p00000069788p
4762040400094930 000214147680001095445120000462680660000812678980000872152370000580503800000626533310001411425950001035889150001011675240000930959670001031754130

The rows are divided into one column of 19 chars and 12 of 12 chars. Each of the 12 chars columns represents a decimal and if it ends on p it should be negative.
The first 2 lines are converted successfully but the 3rd line throws an error on Columns 3, 9, 10, 11 & 13 and returns NULL values.
The code used to transform the columns is the following.
SUBSTRING([Column 2],12,1) == "p" ? (DT_NUMERIC,12,3)SUBSTRING([Column 2],1,11) * @[User::Negative] : (DT_NUMERIC,12,3)SUBSTRING([Column 2],1,12) * @[User:Tongueositive]


Do you have any idea on what's happening? Should I use something different for this instead of the derived column?

If more info is needed, please tell me.


Could it be because you've included the "sign" character "0" in your positive number by using ...

(DT_NUMERIC,12,3)SUBSTRING([Column 2],1,12) * @[User:Tongueositive]

... instead of ...

(DT_NUMERIC,12,3)SUBSTRING([Column 2],1,11) * @[User:Tongueositive]

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)

Group: General Forum Members
Points: 43541 Visits: 19862
Thank you Jeff,
Your suggestion gave me an idea. It was actually a precision problem. I just changed to a larger precision and it was fixed. :-)
Code turned out like this.

SUBSTRING([Column 2],12,1) == "p" ? (DT_NUMERIC,16,3)SUBSTRING([Column 2],1,11) * @[User::Negative] : (DT_NUMERIC,16,3)SUBSTRING([Column 2],1,12) * @[User:Tongueositive]



Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search