Click to See Complete Forum and Search --> : A small problem.


kozak_adam
01-28-2008, 01:07 PM
Hi I was wondering if anyone has any ideas.

I am just doing a simple select using a LEFT(). It looks like this:

SELECT LEFT(column1, charindex('_', column1))
FROM Table

When the Query is run, I get what I want, but it comes with the "_" delimiter on it. I want to know how I can get it off, because using:

SELECT LEFT(column1, charindex('_', column1)-1)
FROM Table

Does not work. I get an error about an invlaid length variable to be used in the function.

I have tried a few other thigns, but nothing is working, and I have run out of ideas.

any suggestions?

chazzy
01-28-2008, 07:30 PM
i think you have to add some error checking - what happens if _ isn't found?