REMOVE ALL AFTER CERTAIN CHARACTER

Jeet Verma

Total Post:110

Points:776
Posted by  Jeet Verma
C# 
C#
 1160  View(s)
Ratings:
Rate this:

Hi Everyone!

I have got a C# project and some data like:

Thinness (n.)
Slenderness (n.)
A fat lot
Hefty (a.)
Tucking of loincloth
I want these data just like that below

Thinness
Slenderness
A fat lot
Hefty
Tucking of loincloth
I tried

UPDATE    dic
SET  english = LEFT(english, CHARINDEX('(', english) - 1)
WHERE  (CHARINDEX('(', english) > 0)
But I get error:

Token in error LEFT

How can I handle that?

Thanks in advance

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Remove all after certain character

    Hi Jeet!

    In place of LEFT used SUBSTRING as below

    UPDATE    dic
    SET  english = SUBSTRING(english, 1, CHARINDEX('(', english) - 1)
    WHERE  (CHARINDEX('(', english) > 0)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!