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

Problem with data conversion Expand / Collapse
Author
Message
Posted Wednesday, August 28, 2013 10:47 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 9:26 AM
Points: 3,547, Visits: 7,663
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::Positive]


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.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1489326
Posted Wednesday, August 28, 2013 1:50 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 11:26 AM
Points: 13,622, Visits: 10,514
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?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1489403
Posted Wednesday, August 28, 2013 3:30 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 9:26 AM
Points: 3,547, Visits: 7,663
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.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1489434
Posted Wednesday, August 28, 2013 5:04 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 9:58 AM
Points: 36,995, Visits: 31,517
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::Positive]


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::Positive]

... instead of ...

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


--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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1489466
Posted Wednesday, August 28, 2013 5:31 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 9:26 AM
Points: 3,547, Visits: 7,663
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::Positive]





Luis C.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1489473
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse