I have a text field in a table. The field has subheadings and I want to extract the data under each subheading and create a columns named after the subheading.
For example:
ID. Text
1 NAME: abc. COMPANY: cuz. ADDRESS: dfg
Required output:
ID Name Company Address
1. abc Cuz dfg
I tried substring with charindex to get the position of the Subheading, but I am unable to get the length right. The text under each subheading is of variable length.
2条答案
按热度按时间py49o6xq1#
Updated considering new information. In the future, please be more careful and considerate
Example
Results
btqmn9zl2#
As others have stated, you should provide more data. But I will take a guess at what you want. Note that there are quite a few assumptions here.
Either way, this is what I would do.
Note that depending on indexes, volume of data, etc., you may need to use interim tables (I personally like to use temp tables).