SQL extract string based on character

Example: MyText field value = "String1 / String2"

The following SQL command will extract/retain the string value preceding a specified character. Any string preceding the "/" character will be captured.

The resulting MyText field value will be "String1"


SET MyText = SUBSTRING(MyText,1, CHARINDEX('/', MyText)-1)WHERE CHARINDEX('/', MyText)>0

 I found this article helpful. (0)