I need a query to seperate "GL_CODE" into different columns based the "." as the delimiter.
I have attached a screenshot of the setup i have done, but im getting error after extracting the 7th segment.
Note that the elements in each are not having same string length for every line.
Code that I have used:
select
YEAR, PERIOD, AMOUNT,
SUBSTRING(GL_CODE, 1, 3) AS segment1,
SUBSTRING(GL_CODE, CHARINDEX('.', GL_CODE, 1) + 1, CHARINDEX('.', GL_CODE, (CHARINDEX('.', GL_CODE, 1)))) AS segment2
FROM
TAG_ENTITY_GL_YTD_BAL