![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am using a dts package to move data from a .txt file to a data table. In that file, there are two columns of information that I need to combine into one column in the table. here is an example: col1 col2 xyz123 <null xyz234 <null null> abc333 null> abc757 If every instance, if there is a value in column 1 there will be a <null> in column 2. The same is true in the reverse. I want the data in the table after the move to look like this: combined column xyz123 xyz234 abc333 abc757 However, when I do the transformation, the package appends the word null to the field. so my actual data looks like this: actual xyz123null xyz234null nullabc333 nullabc757 Here is the activex script: //************************************************** ******* ************* // Java Transformation Script //************************************************** ******* *************** // Copy each source column to the destination column function Main() { DTSDestination("CLO") = DTSSource("Col009") + DTSSource("Col010"); return(DTSTransformStat_OK); } Help!! Marcus |
#3
| |||
| |||
|
|
-----Original Message----- Easiest way? I would import to a working table. You can then use COALESCE() to get the first NON Null value so COALESCE(col1,col2) will give you whichever attribute is not null from the two. You can insert this to your real table -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "marcus" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:1a3f301c44e23$f816c440$a101280a (AT) phx (DOT) gbl... I am using a dts package to move data from a .txt file to a data table. In that file, there are two columns of information that I need to combine into one column in the table. here is an example: col1 col2 xyz123 <null xyz234 <null null> abc333 null> abc757 If every instance, if there is a value in column 1 there will be a <null> in column 2. The same is true in the reverse. I want the data in the table after the move to look like this: combined column xyz123 xyz234 abc333 abc757 However, when I do the transformation, the package appends the word null to the field. so my actual data looks like this: actual xyz123null xyz234null nullabc333 nullabc757 Here is the activex script: //************************************************** **** *** ************* // Java Transformation Script //************************************************** **** *** *************** // Copy each source column to the destination column function Main() { DTSDestination("CLO") = DTSSource("Col009") + DTSSource("Col010"); return(DTSTransformStat_OK); } Help!! Marcus . |
#4
| |||
| |||
|
|
Allan, Thanks for your help. I have never used COALESCE(). Not sure where I would use that function. Is it not possible to modify the ActiveX script to "ignore" the null? Or, to filter out the word null during the transformation? Marcus -----Original Message----- Easiest way? I would import to a working table. You can then use COALESCE() to get the first NON Null value so COALESCE(col1,col2) will give you whichever attribute is not null from the two. You can insert this to your real table -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "marcus" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:1a3f301c44e23$f816c440$a101280a (AT) phx (DOT) gbl... I am using a dts package to move data from a .txt file to a data table. In that file, there are two columns of information that I need to combine into one column in the table. here is an example: col1 col2 xyz123 <null xyz234 <null null> abc333 null> abc757 If every instance, if there is a value in column 1 there will be a <null> in column 2. The same is true in the reverse. I want the data in the table after the move to look like this: combined column xyz123 xyz234 abc333 abc757 However, when I do the transformation, the package appends the word null to the field. so my actual data looks like this: actual xyz123null xyz234null nullabc333 nullabc757 Here is the activex script: //************************************************** **** *** ************* // Java Transformation Script //************************************************** **** *** *************** // Copy each source column to the destination column function Main() { DTSDestination("CLO") = DTSSource("Col009") + DTSSource("Col010"); return(DTSTransformStat_OK); } Help!! Marcus . |
#5
| |||
| |||
|
|
-----Original Message----- It is yes but the problem with the Active Script transform is that it does everything row*row. Import the file to a working table. Can I guess that the file when you say NULL has the word NULL and not a blank space? In an Active Script transform you could do If DTSSource("Col1") = "NULL" THEN DTSDestination("Col") = DTSSource("Col2") Else DTSDestination("Col") = DTSSource("Col1") End if This is following the rule that only one of these columns will have a value you want to use. -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "marcus" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:1a5dc01c44e29$aace29c0$a001280a (AT) phx (DOT) gbl... Allan, Thanks for your help. I have never used COALESCE(). Not sure where I would use that function. Is it not possible to modify the ActiveX script to "ignore" the null? Or, to filter out the word null during the transformation? Marcus -----Original Message----- Easiest way? I would import to a working table. You can then use COALESCE() to get the first NON Null value so COALESCE(col1,col2) will give you whichever attribute is not null from the two. You can insert this to your real table -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "marcus" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:1a3f301c44e23$f816c440$a101280a (AT) phx (DOT) gbl... I am using a dts package to move data from a .txt file to a data table. In that file, there are two columns of information that I need to combine into one column in the table. here is an example: col1 col2 xyz123 <null xyz234 <null null> abc333 null> abc757 If every instance, if there is a value in column 1 there will be a <null> in column 2. The same is true in the reverse. I want the data in the table after the move to look like this: combined column xyz123 xyz234 abc333 abc757 However, when I do the transformation, the package appends the word null to the field. so my actual data looks like this: actual xyz123null xyz234null nullabc333 nullabc757 Here is the activex script: //************************************************** **** *** ************* // Java Transformation Script //************************************************** **** *** *************** // Copy each source column to the destination column function Main() { DTSDestination("CLO") = DTSSource("Col009") + DTSSource("Col010"); return(DTSTransformStat_OK); } Help!! Marcus . . |
#6
| |||
| |||
|
|
-----Original Message----- It is yes but the problem with the Active Script transform is that it does everything row*row. Import the file to a working table. Can I guess that the file when you say NULL has the word NULL and not a blank space? In an Active Script transform you could do If DTSSource("Col1") = "NULL" THEN DTSDestination("Col") = DTSSource("Col2") Else DTSDestination("Col") = DTSSource("Col1") End if This is following the rule that only one of these columns will have a value you want to use. -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "marcus" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:1a5dc01c44e29$aace29c0$a001280a (AT) phx (DOT) gbl... Allan, Thanks for your help. I have never used COALESCE(). Not sure where I would use that function. Is it not possible to modify the ActiveX script to "ignore" the null? Or, to filter out the word null during the transformation? Marcus -----Original Message----- Easiest way? I would import to a working table. You can then use COALESCE() to get the first NON Null value so COALESCE(col1,col2) will give you whichever attribute is not null from the two. You can insert this to your real table -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "marcus" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message news:1a3f301c44e23$f816c440$a101280a (AT) phx (DOT) gbl... I am using a dts package to move data from a .txt file to a data table. In that file, there are two columns of information that I need to combine into one column in the table. here is an example: col1 col2 xyz123 <null xyz234 <null null> abc333 null> abc757 If every instance, if there is a value in column 1 there will be a <null> in column 2. The same is true in the reverse. I want the data in the table after the move to look like this: combined column xyz123 xyz234 abc333 abc757 However, when I do the transformation, the package appends the word null to the field. so my actual data looks like this: actual xyz123null xyz234null nullabc333 nullabc757 Here is the activex script: //************************************************** **** *** ************* // Java Transformation Script //************************************************** **** *** *************** // Copy each source column to the destination column function Main() { DTSDestination("CLO") = DTSSource("Col009") + DTSSource("Col010"); return(DTSTransformStat_OK); } Help!! Marcus . . |
![]() |
| Thread Tools | |
| Display Modes | |
| |