表格详情如下:
REPORT_ID ATTR VALUE
INV_2017-08-29T06:00:00 /s-1/ /s-1/|7500|25|LPG|3610.94870820629|3526.84971279216|3523.3882574674
答案 0 :(得分:0)
如果您正在使用XML
SQL Server
节点方法
select distinct REPORT_ID, ATTR,
a.value ('/A[1]', 'VARCHAR(MAX)') [Value1],
a.value ('/A[2]', 'VARCHAR(MAX)') [Value2],
a.value ('/A[3]', 'VARCHAR(MAX)') [Value3],
a.value ('/A[4]', 'VARCHAR(MAX)') [Value4],
a.value ('/A[5]', 'VARCHAR(MAX)') [Value5],
a.value ('/A[6]', 'VARCHAR(MAX)') [Value6],
a.value ('/A[7]', 'VARCHAR(MAX)') [Value7]
from
(
SELECT REPORT_ID, ATTR, CAST('<A>'+REPLACE(Value,'|', '</A><A>')+'</A>' AS XML) AS Value
FROM [AmmDb].[dbo].[IP_REPORT]
) A CROSS APPLY Value.nodes ('/A') as split(a)
结果:
REPORT_ID ATTR Value1 Value2 Value3 Value4 Value5 ..... Value7
INV_2017-08-29T06:00:00 /s-1/ /s-1/ 7500 25 LPG 3610.94870820629 3523.3882574674