sql server - SQL select to get a string between two spaces -
i have field names in format doe john howard or doe john h.
i need query string between 2 spaces (john in case).
the answer here shows how when desired substring between 2 different strings, don't see how apply similar when desired substring between 2 instances of same string (a space in case).
how can that?
one way:
select left(substring(fld, charindex(' ', fld) + 1, len(fld)), charindex(' ', substring(fld, charindex(' ', fld) + 2, len(fld))))
Comments
Post a Comment