答案 0 :(得分:0)
我确信有比这更优雅的解决方案
if object_id('tempdb..#init') is not null begin drop table #init end;
SELECT PL.RECORD_ID, PL.PRINTER_LEVELS
INTO #INIT
FROM PRINT_LOG PL
WHERE PL.INSTANT_OF_PRI_DTTM BETWEEN '2018-04-26 00:00:00.000' and '2018-04-27 00:00:00.000'
SELECT F1.RECORD_ID,
F1.PRINTER_LEVELS,
O.splitdata
FROM
(
SELECT *,
cast('<X>'+replace(F.PRINTER_LEVELS,':','</X><X>')+'</X>' as XML) as xmlfilter from #INIT F
)F1
CROSS APPLY
(
SELECT fdata.D.value('.','varchar(254)') as splitdata
FROM f1.xmlfilter.nodes('X') as fdata(D)) O