I have a column consisting of strings of the like abc_defg_ghi_jklmn etc. The number of characters after and before the delimiter is dynamic. For this example, I wish to split the string into 4 columns.
Output (in this case) would look like -
col1 : abc
col2 : defg
col3 : ghi
I was able to achieve this but the query is exceptionally long with combinations of substring and charindex, and confusing to others who read it.
Is there a better way to go about this? Please recommend, and the query to help understand the solution. I'm using MS SQL Server Management Studio 17.