February 27, 2007 at 2:36 pm
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.
February 28, 2007 at 10:10 am
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')
February 28, 2007 at 11:55 am
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.
February 28, 2007 at 3:14 pm
Try REPLACE([AssetDescr], "\"","in")
Leonce
March 15, 2007 at 12:41 pm
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')
October 1, 2007 at 10:29 am
The use of an SSIS variable can be used for the " character and that will allow the replace to function correctly.
Glen
May 14, 2008 at 9:07 am
Thanks, it worked.
February 12, 2009 at 7:04 am
Thanks it worked.
Thanks a lot
August 20, 2010 at 7:33 pm
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.
December 17, 2010 at 2:40 pm
Use Leonce suggestion above "... REPLACE([AssetDescr], "\"","in")" it works.
January 14, 2011 at 2:47 am
Check out this link. It is just one step quick way.
January 14, 2011 at 7:04 am
munawargani2001 (1/14/2011)
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
September 9, 2011 at 7:53 pm
Thanks for the post, this really helped me. the variable is the only way to handle this situation.
September 12, 2011 at 9:12 am
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.
September 12, 2011 at 12:22 pm
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