Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 SSIS HELP

Author  Topic 

jscot
Posting Yak Master

106 Posts

Posted - 2011-03-28 : 22:12:23
Here is my sample data

ID,TABLEA,TABLEB

1,CA ,NULL

2,NULL,GA

3,MA,NULL

I am mapping TableB(Source field ) to my target field. and if TableB is Null use TableA value. I am using this expression

"NULL"? [COLUMN_B] : [COLUMN_A] ( still red on derived column ) Need help to fix this issue, I want to know where i am wrong.




CREATE TABLE SAMPLE

(

ID INT,

COLUMN_A VARCHAR(5),

COLUMN_B VARCHAR(5)

)



INSERT INTO SAMPLE (ID,COLUMN_A,COLUMN_B )VALUES ('1','CA','NULL')

INSERT INTO SAMPLE (ID,COLUMN_A,COLUMN_B )VALUES ('2','NULL','GA')

INSERT INTO SAMPLE (ID,COLUMN_A,COLUMN_B )VALUES ('3','MA','NULL')



Please help me if i want to use more than two columns how i can expand this expression.

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2011-03-29 : 15:49:26
can you use COALESCE function

If you don't have the passion to help people, you have no passion
Go to Top of Page

jscot
Posting Yak Master

106 Posts

Posted - 2011-03-30 : 22:07:02
Yosiasz i am not familiar with "COALESCE" Function, Please let me know if you can help me more about this issue. Thanks.
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2011-04-01 : 11:35:03
returns the first not null value COALESCE(Class, Color, ProductNumber) AS FirstNotNull

If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -