March 15, 2011 at 7:02 pm
Here is my source data
Description
D-1,D2
D-2,D-U,T1
U-5,T2,K-5,T3
NULL
Here is the expressions i am using in "Derived Column"
Col1 = SUBSTRING(Description,1,FINDSTRING(Description,",",1) - 1)
Col2 = SUBSTRING(Description,FINDSTRING(Description,",",1) + 1,FINDSTRING(Description,",",2) - FINDSTRING(Description,",",1) - 1)
Col3 = SUBSTRING(Description,FINDSTRING(Description,",",2) + 1,LEN(Description))
Col4 = Need help for expression
Note:- I am receiving error "Disposition" Error. Please help me out where i am wrong. Thanks in advance
March 15, 2011 at 8:02 pm
jscot91 (3/15/2011)
Here is my source dataDescription
D-1,D2
D-2,D-U,T1
U-5,T2,K-5,T3
NULL
Here is the expressions i am using in "Derived Column"
Col1 = SUBSTRING(Description,1,FINDSTRING(Description,",",1) - 1)
Col2 = SUBSTRING(Description,FINDSTRING(Description,",",1) + 1,FINDSTRING(Description,",",2) - FINDSTRING(Description,",",1) - 1)
Col3 = SUBSTRING(Description,FINDSTRING(Description,",",2) + 1,LEN(Description))
Col4 = Need help for expression
Note:- I am receiving error "Disposition" Error. Please help me out where i am wrong. Thanks in advance
No reflection on you but a lot of folks make some pretty good mistakes in their functions without even realizing it. Please post the code for the FINDSTRING function you're using.
Also, please verify that you're using SQL Server 2005.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 15, 2011 at 8:17 pm
Thanks for prompt reply, I am using SQL Server 2008. I am sorry i don't understand which code? I am using SSIS and this expression in derived column transformation. Thanks.
March 15, 2011 at 11:33 pm
Hi,
Data of this kind could be broke down using split function available in VB.Net.Hence instead of using derived column transformation with substring function , same result would be obtained by using script component by chopping input string using delimiter (comma in your case).
Thanks and Regards,
Gurulakshmanaprabhu Gurusamy
March 16, 2011 at 6:06 am
Gurulakshmanaprabhu Gurusamy (3/15/2011)
Hi,Data of this kind could be broke down using split function available in VB.Net.Hence instead of using derived column transformation with substring function , same result would be obtained by using script component by chopping input string using delimiter (comma in your case).
Thanks and Regards,
Gurulakshmanaprabhu Gurusamy
Yes it could. Why anyone would need to step outside of SQL for a simple problem like this is another story. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2011 at 6:09 am
jscot91,
We need to know something to wrap it up with code, though. What is the code for FINDSTRING?
We're just trying to help here.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2011 at 6:14 am
Description
D-1,D2
D-2,D-U,T1
U-5,T2,K-5,T3
NULL
Is that real sample data? Or have you tidied it up to remove trailing commas, perhaps?
If it is real, you are going to get errors with your derived columns in cases where there are fewer than four fields.
One option may be to pre-process the file and add in the necessary number of trailing commas, then let SSIS import it as a standard CSV file. Then SSIS gets to do the parsing for you.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
March 16, 2011 at 7:29 pm
Phil Parkin (3/16/2011)
JeffFINDSTRING is a built-in SSIS function, see here.
Ah! Thanks, Phil... That's what I get when I post on a forum for something I don't use. :blush: It appears to be similar to CHARINDEX in T-SQL with the added sophistication of being able to indentify which occurance you want to find. Thanks again.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2011 at 7:32 pm
Ok... I'm pretty much ignorant of SSIS. My question at this point is why couldn't one of the common split functions written in T-SQL work here for the OP?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2011 at 7:51 pm
Jeff Moden (3/16/2011)
Ok... I'm pretty much ignorant of SSIS. My question at this point is why couldn't one of the common split functions written in T-SQL work here for the OP?
Because you can't use a function from SQL in a derived column, and to try to do so would interrupt the stream, forcing a block at a point, slowing the process down.
OP: Can you post the full error you're getting in the debug output? Or from the errors list if it's not compiling at all?
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[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
March 16, 2011 at 8:13 pm
Nevermind, I see the problem. You don't have evaluations in your strings, as Phil mentioned earlier. You need to test findstring to see if it found the character
IE: FINDSTRING( col, ",", 3) != 0 (Yes, SSIS still uses this archaic form of not equals)
then use the if/then/else structure to deal with it:
fxn == 0 ? dt_null : substring()
Replace FXN with your finding function, the substring with the extractor function, and (dt_null) with the nullable datatype version of whatever string format you want in the string (you can find them in the datatypes node in the upper right).
You may, if you don't have trailing commas, need to test the tail of the string in a nested if function (which is described by the ? : structure) to see what form of the substring function you'll need to use.
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[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
March 17, 2011 at 6:30 am
Craig Farrell (3/16/2011)
Jeff Moden (3/16/2011)
Ok... I'm pretty much ignorant of SSIS. My question at this point is why couldn't one of the common split functions written in T-SQL work here for the OP?Because you can't use a function from SQL in a derived column, and to try to do so would interrupt the stream, forcing a block at a point, slowing the process down.
Really?! Don't ya just love the interoperability between SQL Server products? 😛 Thanks, Craig.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 17, 2011 at 6:37 am
Yes, SSIS still uses this archaic form of not equals
Not that archaic ... so does C#.NET 🙂
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
March 17, 2011 at 6:49 am
Jeff Moden (3/16/2011)
jscot91,We need to know something to wrap it up with code, though. What is the code for FINDSTRING?
We're just trying to help here.
Jeff, stop interfering in SSIS threads. 😛 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 15 posts - 1 through 15 (of 22 total)
You must be logged in to reply to this topic. Login to reply