Link to home
Start Free TrialLog in
Avatar of C G
C GFlag for Kenya

asked on

LTRIM(LTRIM.....

Hi Experts,

I am using the derived column transformation for my package and i have a column that has the name of a city, state and company name.. 'New York, NY-The First Bank'. My goal is to grab only the company name, and put it in another column. I am using the LTRIM Expression

LTRIM(SUBSTRING([Customer Name],FINDSTRING([Customer Name],"-",1),LEN([Customer Name])))

This is grabbing the company name along with the '-'.  Any suggestions on how i can get rid of the '-', I have tried to use 2 LTRIM's but it gives me the same result.


Thank you.. :)
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

LTRIM(RTRIM(SUBSTRING([Customer Name],CHARINDEX('-', [Customer Name]) - 1,8000)))
Avatar of C G

ASKER

Getting error message, it does not recognize the CHARINDEX..
Then you must not be using SQL Server.

I guess go back to FINDSTRING, as in your original post, just add the "- 1" after the SUBSTRING:

LTRIM(SUBSTRING([Customer Name],FINDSTRING([Customer Name],"-",1) - 1,LEN([Customer Name])))
ASKER CERTIFIED SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of C G

ASKER

+1 did the trick.. Thank you. :)