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

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -