views:

968

answers:

3

I have a table with 5 string columns, all can be NULLs. After I read the data from this table, I want to convert any null values into empty strings. The reason is that I need to compare these columns with columns in another table of the same schema (using conditional split), and null values would cause the comparison to evaluate to NULL.

Is there any functionality in SSIS that allows me to convert NULL's to empty strings, or just not having to deal with NULL's at all?

+1  A: 

You can use a Derived Column transform. I don't have VS open now, but you'd use something like:

IIF(ISNULL(column)?"":column)

as the expression, and have it replace the original column.

John Saunders
+1  A: 

In your query wrap your columns as follows...

SELECT ISNULL(col1,'') AS [col1]
      ,ISNULL(col2,'') AS [col2]
      ,ISNULL(col3,'') AS [col3]
      ,ISNULL(col4,'') AS [col4]
      ,ISNULL(col5,'') AS [col5]
CptSkippy
This is the version that I would prefer as SQL DBA/DB Developer, if you're specifying the query for your input then adding ISNULL around your columns is pretty easy to do and that way you don't have to do any additional transformations in SSIS. If you're developing a lot of SSIS packages with tables that sometimes have NULLs allowed and sometimes don't you could also create a script to create your SELECT statement with the ISNULL function for you only for columns that are nullable.
Jeff
+2  A: 

The correct syntax is (ISNULL(column)?"":column) without the IIF