I have a resultset consisting of 1 column and in this case 2 rows the single column [ProductDescription] is a varchar field that hold 3 pieces of information (I didn't design it) i need to get those three pieces of information out into 3 additional fields using a query
before
/------------------------------\ |ProductDescription | |------------------------------| |DB1 - DB2 - DB3 | |DataBit1 - DataBit2 - DataBit3| \------------------------------/
After
/---------------------------------------------------------\ |Field1 |Field2 |Field3 |ProductDescription | |---------------------------------------------------------| |DB1 |DB2 |DB3 |DB1 - DB2 - DB3 | |DataBit1|DataBit2|DataBit3|DataBit1 - DataBit2 - DataBit3| \---------------------------------------------------------/
I have tried using combinations of Substring and charindex but haven't been able to get it quite right, each part of the field could be any length so using hardcoded offsets doesn't work.