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.. :)
C GAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
LTRIM(RTRIM(SUBSTRING([Customer Name],CHARINDEX('-', [Customer Name]) - 1,8000)))
C GAuthor Commented:
Getting error message, it does not recognize the CHARINDEX..
Scott PletcherSenior DBACommented:
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])))
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

chaauCommented:
Scott is right. The only correction will be to use +1:
LTRIM(SUBSTRING([Customer Name],FINDSTRING([Customer Name],"-",1) + 1,LEN([Customer Name]))) 

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulEE Topic AdvisorCommented:
C GAuthor Commented:
+1 did the trick.. Thank you. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.