sql - split one column to multiple named columns -


during recent restore , issue occurred may or may not have been present before i'm aware of have been tasked coming solution it. write data multiple column names each row i've found fields going overflow column. below example of have.

columns should have data in:

flddate - fldname    - fldphonenumber - fldtransactionid - fldoverflow     8/15/13 - john smith - 1012023344     - 123456789        - null 

what getting:

flddate - fldname    - fldphonenumber - fldtransactionid - fldoverflow    8/15/13 - null       - null           - null             - fldname="john smith", fldphonenumber="1012023344", fldtransactionid="123456789" 

what need:

i need find way fldoverflow field data correct fields. appreciated.

there numerous functions out there separating delimited field multiple columns, that's option, use coalesce() , string manipulation, like:

select  flddate        , fldname = coalesce(fldname, substring(fldoverflow,charindex('fldname="',fldoverflow)+9,charindex(', fldphone',fldoverflow)-charindex('fldname="',fldoverflow)-10))       , fldphonenumber        , fldtransactionid       , fldoverflow  table 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -