sql server 2008 - split ssrs expression between 2 words -
i have requirement split result 3 separate expressions, using sql server 2008.
the result example. "person: man tel: yes rel: christian msg: misc text"
i need split into:
"person: man" "tel: yes" "rel: christian" "msg: misc text"
i have been using iif statement return bit before "tel" cant return between tel , rel etc. part before colon remain static whichever result returned in dataset, part after colon (of length too) before getting next section. can please? other similar questions on forum have been helpful first expression, later ones little more difficult.
for sql method works test did:
select left(txt, charindex('tel:',txt)-2) part1, substring(txt, charindex('tel:',txt), charindex('rel:',txt)-charindex('tel:',txt)) part2, substring(txt, charindex('rel:',txt), charindex('msg:',txt)-charindex('rel:',txt)) part3, right(txt, len(txt)-charindex('msg:',txt)+1) part4 ( select 'person: man tel: yes rel: christian msg: misc text' txt ) t
Comments
Post a Comment