How to replace double quotes in derived column transformation?

I think you have almost got the expression correct except for the additional slash in the replacement string. Here are the expressions that might work for you.

Expression #1: Removes all double quotes within a given string.

REPLACE(COLA, "\"", "")

Expression #2: Replaces all double occurrences of double quotes with single occurrence of double quotes.

REPLACE(COLA, "\"\"", "\"")

Here is an example that demonstrates expression #1:

  1. Screenshot #1 shows the CSV file that will be read by a package.
  2. Screenshot #2 shows the Derived Column transformation inside the Data Flow task that will replace all double quotes within the first column named as Header.
  3. Screenshot #3 shows data in the table after the package execution. Notice that the double quotes in second column are left as it is because there is no expression to replace them.

Here is an example that demonstrates expression #2:

  1. This example will use the same file as in example 1. Refer screenshot #1.
  2. Screenshot #4 shows the Derived Column transformation inside the Data Flow task that will replace all double occurrences of double quotes with single occurrence of double quotes within the first column named as Header.
  3. Screenshot #5 shows data in the table after the package execution. Notice that the double quotes in second column are left as it is because there is no expression to replace them.

Hope that helps.

Screenshot #1:

1

Screenshot #2:

2

Screenshot #3:

3

Screenshot #4:

4

Screenshot #5:

5

Leave a Comment