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.
Author |
Topic |
jscot
Posting Yak Master
106 Posts |
Posted - 2011-03-28 : 22:12:23
|
Here is my sample dataID,TABLEA,TABLEB1,CA ,NULL2,NULL,GA3,MA,NULLI 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 functionIf you don't have the passion to help people, you have no passion |
|
|
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. |
|
|
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 FirstNotNullIf you don't have the passion to help people, you have no passion |
|
|
|
|
|
|
|