David
David

Reputation: 57

Replace blank with another column value in SSIS derived column Transformation

I need to replace the blank value with the column Data2 Original Table

            +-------+--------+
            | data1 | Data2  |
            +-------+--------+
            | 45789 |  45789 |
            | 56897 |  56897 |
            |       |  56897 |
            | 56485 |  56485 |
            |       | 897458 |
            +-------+--------+

Expected Table

            +-------+--------+
            | data1 | Data2  |
            +-------+--------+
            | 45789 |  45789 |
            | 56897 |  56897 |
            | 56897 |  56897 |
            | 56485 |  56485 |
            | 897458| 897458 |
            +-------+--------+

I tried this not working

 data1 == "" ? data1 : data2

Upvotes: 1

Views: 421

Answers (1)

Ehsan HP
Ehsan HP

Reputation: 492

Your expression is true if two columns have the same data type. If data types are different, you need to cast the data2 column.

enter image description here

Enable data viewer to check your result, It works properly:

enter image description here

You can also use another way. Write a TSQL query to replace the Data1 column with Data2 Column

SELECT 
       CASE WHEN Data1 = '' THEN Data2 ELSE Data1 END  Data1
      ,Data2
FROM YourTable

Upvotes: 2

Related Questions