sql - Extracting pipe delimted field into rows -


i have tbl field values pipe delimited, , need them extracted rows.

sample data

select distinct [prov_key],  [ntwk_cds] [spock].[us\ac39169].[wellpointextract_err] [prov_key] = '447358b0a8e1c0f1b7aeb1ed07ec2f25' --results prov_key    ntwk_cds 447358b0a8e1c0f1b7aeb1ed07ec2f25    |ga_hmo|ga_opn|ga_ppo|ga_bd|ga_mcppo|ga_hdppo| 

and like:

prov_key                                          ntwk_cds 447358b0a8e1c0f1b7aeb1ed07ec2f25                  ga_hmo 447358b0a8e1c0f1b7aeb1ed07ec2f25                  ga_opn 447358b0a8e1c0f1b7aeb1ed07ec2f25                  ga_ppo 

i tried following i'm getting first set of values:

select distinct [prov_key],  substring([ntwk_cds], 1,  charindex('|',[ntwk_cds], charindex('|',[ntwk_cds])+1))  [spock].[us\ac39169].[wellpointextract_err] [prov_key] = '447358b0a8e1c0f1b7aeb1ed07ec2f25' 

this standard string splitting problem , there many solutions out there. still feel workaround, sql server not have split function build in.

you can start research here: http://www.sommarskog.se/arrays-in-sql.html


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -