SSIS REPLACE Double Quote

  • I was trying to use the Replace function in the Derived Column transform to strip double quotes (abbrev for inches as in 6'4") out of a data field, but couldn't get the syntax right.  Here is what I tried unsuccessfully:

    REPLACE([AssetDescr], ""","in")

    Does anyone have a syntax that works here?

    As a workaround, I modified the SQL query in the OLEDB Source with the SQL REPLACE function, but I was just wondering if it can be done via the Derived Column.

  • Haven't tried this in SSIS, but it looks like you have 3 double quotes in a row.  Try to enclose it search value with single quotes?

    REPLACE

    ([AssetDescr], '"','in')

  • I already tried that but it also failed.  In the Derived Column transform, even though the commands appear to be SQL, apparently they are not.  I have found that string values must be enclosed in double quotes.

  • Try REPLACE([AssetDescr], "\"","in")

    Leonce

  • Within TSQL you could try - but with your column name instead of the local variable of course.

    declare @AssetDescr VARCHAR(30)

    set @AssetDescr= 'This has quotes at 6".'

    select @AssetDescr

    SELECT REPLACE(@AssetDescr, '"','in')

  • The use of an SSIS variable can be used for the " character and that will allow the replace to function correctly.

    Glen

  • Thanks, it worked.

  • Thanks it worked.

    Thanks a lot

  • Can anybody suggest me how to use the replace function in derived column transformation.

    I have a expression REPLACE(UPPER(NAME),@[User::Quote]," ") but this is not replacing quote in destination.

  • Use Leonce suggestion above "... REPLACE([AssetDescr], "\"","in")" it works.

  • Check out this link. It is just one step quick way.

    http://www.mssqltips.com/tip.asp?tip=1316

  • munawargani2001 (1/14/2011)


    Check out this link. It is just one step quick way.

    http://www.mssqltips.com/tip.asp?tip=1316%5B/quote%5D

    This will work if the data comes out of a flat file.

    However, no one in this thread has mentioned anything about flat files.

    Furthermore, the original question mentions an OLE DB Source, so the data comes out of a database.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Thanks for the post, this really helped me. the variable is the only way to handle this situation.

  • sjohnson022 (9/9/2011)


    Thanks for the post, this really helped me. the variable is the only way to handle this situation.

    Could you post what your replace expression looks like with the variable in use? I'm having trouble visualizing the solution.

  • What's your question peterzeke? This thread is very old, with several different questions and answers within.

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply