Ok, I’ll hit him too and see if I can simplify:
SELECT LEFT(myfield', CHARINDEX(' - ', myfield) - 1)
When wrapping -in spaces, the delimiter is less likely to work, and there is no need to trim the result.
Caution: this, like other answers, will result in an error if it myfielddoes not contain a separator -.
Ultimately, if your table always has a dotted delimiter, you should have two fields.
source
share