SSIS REPLACE Function - Derived Column

I have a variable with a value of '1617'. It is a DT_WSTR datatype currently. Sometimes I need a string, others an integer.

I am using a derived column to replace the ' values so that I can cast this value as an integer.

My replace function is not working.

REPLACE([User::schoolYear],"'","")

What am I doing wrong?

Upvotes: 0

Views: 2218

Answers (2)

billinkc
billinkc

Reputation: 61211

The problem with your supplied expression, is that you are not referencing the variable schoolYear. Sometimes, you can address a variable as @schoolYear but the consistent, explicit syntax I would encourage is @[User::schoolYear] That way, you can identify the namespace in case someone like me has used a custom namespace.

Your Derived Column expression then becomes

REPLACE(@[User::schoolYear],"'","")

Upvotes: 2

Venkataraman R
Venkataraman R

Reputation: 12959

You are having space before and after the single quote, which is causing the replace to fail.

Modify the expression as given below. I have tested it. It is working fine.

REPLACE([User::schoolYear],"'","")

Upvotes: 1

Related Questions