IF OBJECT_ID('TC58','U') IS NOT NULL BEGIN
DROP TABLE TC58
END
GO
CREATE TABLE TC58(
ID INT IDENTITY PRIMARY KEY,
Layout VARCHAR(MAX)
)
GO
--INSERT INTO TC58(Layout) SELECT 'rnbqk2r/ppppbppp/5n2/4p3/2B1P3/5Q2/PPPP1PPP/RNB1K1NR'
--INSERT INTO TC58(Layout) SELECT 'rnbq3r/pppp2pp/8/2ppp3/2B1K3/5P2/PPP2PPP/RNB3NR'
INSERT INTO TC58(Layout) SELECT '4r3/1k6/pN1p4/3P1p1p/3B4/3K1n2/PPP4R/8'-- w - - 7 27
--SELECT * FROM TC58
/*
select
0,
SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ) ,
CHARINDEX('/',Layout,0) , --8
SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,
CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) , --17
SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ) ,
CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) , --21
SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1) ,
CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1), --25
SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ) ,
CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) , --31
SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ) ,
CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) , --35
SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),
CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) , --44
SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1))
from TC58
*/
/*
select ID, 8 as RowID , SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ) from TC58
union all
select ID, 7 as RowID ,SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) from TC58
union all
select ID, 6 as RowID ,SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ) from TC58
union all
select ID, 5 as RowID ,SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1) from TC58
union all
select ID, 4 as RowID ,SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ) from TC58
union all
select ID, 3 as RowID ,SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ) from TC58
union all
select ID, 2 as RowID ,SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ) from TC58
union all
select ID, 1 as RowID ,SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)) from TC58
*/
/*
select ID, 8 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
union all
select ID, 7 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
union all
select ID, 6 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
union all
select ID, 5 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
union all
select ID, 4 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
union all
select ID, 3 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
union all
select ID, 2 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
union all
select ID, 1 as RowID ,REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)) from TC58
*/
select ID, 8 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, 0 ,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)) ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
union all
select ID, 7 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,0)+1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,0) - CHARINDEX('/',Layout,0)) ) ,'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
union all
select ID, 6 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+ 1, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
union all
select ID, 5 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)- CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1) -1),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
union all
select ID, 4 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
union all
select ID, 3 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) +1,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1) - 1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
union all
select ID, 2 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) + 1 , CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1) -1 ),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
union all
select ID, 1 as RowID
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),1,1) as 'a'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),2,1) as 'b'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),3,1) as 'c'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),4,1) as 'd'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),5,1) as 'e'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),6,1) as 'f'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),7,1) as 'g'
,substring(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING ( Layout, CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1) +1 ,LEN(layout) - CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,CHARINDEX('/',Layout,0)+1)+1)+1)+1)+1)+1)),'1',REPLICATE(' ',1)),'2',REPLICATE(' ',2)), '3',REPLICATE(' ',3)), '4',REPLICATE(' ',4)), '5',REPLICATE(' ',5)), '6',REPLICATE(' ',6)), '7',REPLICATE(' ',7)), '8',REPLICATE(' ',8)),8,1) as 'h'
from TC58
No comments:
Post a Comment