Sunday, June 25, 2006

[sql] Extract the string up to a delimiter

For example, if the string is '10009-abcde' and we need the characters up to the hyphen.

select substring('10009-abcde', 0, charindex('-', '10009-abcde'))