Splitting a SQL Column with Delimiter in multiple Rows
SELECT T . EMP_ID , RIGHT(LEFT( dbo . MGR_HIERARCHY ( T . ALL_MGR_IN_MGMT_CHAIN )+ ';' , Number - 1 ), CHARINDEX ( ';' , REVERSE (LEFT( ';' + dbo . MGR_HIERARCHY ( T . ALL_MGR_IN_MGMT_CHAIN )+ ';' , Number - 1 )))) as MGR_Hierarchy FROM master .. spt_values , dbo . EMP_MGMT_CHAIN T WHERE Type = 'P' AND Number BETWEEN 1 AND LEN ( dbo . MGR_HIERARCHY ( T . ALL_MGR_IN_MGMT_CHAIN )+ ';' )+ 1 AND ( SUBSTRING ( dbo . MGR_HIERARCHY ( T . ALL_MGR_IN_MGMT_CHAIN )+ ';' , Number , 1 ) = ';' )