我是新手,所以我的术语可能不会抱歉。
好的,所以我在SQL中引用了一些生成这样的表的表。 (我主要理解它)你会看到Parameters列有一个字符串,其中一个列表由一个Pipe" |"还有#"随机字母"之后我需要在以后排序。
[表] [1]
然后将此表用于某些报告软件。
我的问题是我可以将此参数字段拆分为每个参数和值吗?或者只选择我需要的特定参数,或者这完全是个坏主意?
到目前为止这是我的代码[SQL] [2]
很抱歉这是代码,关注的是我在
之后的事情
SELECT [Parts].[Parameters]
FROM [Parts]

返回此
BAND =#SNNNE | ETR =#L2 | SIZE_A =#M1.574803 | SIZE_B =#M7.874016 | SIZE_C =#M29.527559 | SIZE_D =#M47.244094 | SIZE_E =#M70.866142 | SIZE_F = #M86.614173 | SMALL_EDGE_INSET =#M0.590551 | EDGE_INSET =#M1.968504 | SCREW_DIAMETER =#M0.196850 | I_CAM_EDGE_INSET =#M0.374016 | H_CAM_EDGE_INSET =#M0.944882 | I_CAM_DEPTH =#M0.472441 | H_CAM_DEPTH =# M0.472441 | I_CAM_DIAMETER =#M0.787402 | H_CAM_DIAMETER =#M0.590551 | I_PIN_OFFSET =#M0.255906 | H_PIN_OFFSET =#M0.314961 | I_PIN_DEPTH =#M0.472441 | H_PIN_DEPTH =#M0.472441 | I_PIN_DIAMETER =#M0 0.314961 | H_PIN_DIAMETER =#M0.196850 | H_BORE_DIAMETER =#M0.314961 | EDG_NBR =#L4 | ED1TYPE_A =#L1 | EDGE_INSET_B1 =#M1.968504 | C_QTY_B1 =#M0.118110 | QTY_A1 =#M0.118110 | ED2TYPE_A = #L1 | EDGE_INSET_B2 =#M1.968504 | C_QTY_B2 =#M0.118110 | QTY_A2 =#M0.118110 | ED3TYPE_A =#L1 | EDGE_INSET_B3 =#M1.968504 | C_QTY_B3 =#M0.118110 | QTY_A3 =#M0.118110 | ED4TYPE_A =#L1 | EDGE_INSET_B4 =#M1.968504 | C_QTY_B4 =#M0.118110 | QTY_A4 =#M0.118110 | WINGLINE26 =#L1501 | WINGLINE230 =#L1500 | WINGLINE770 =#L1502 | WINGLINE770B =#L1503 | WINGLINE780 =#L1499
答案 0 :(得分:1)
有许多可用的拆分/解析示例。如果2016年您可以使用String_Split()
以下是一个内联示例
示例强>
Select A.ID
,Item = left(B.RetVal,charindex('=',B.RetVal+'=')-1)
,Value = right(B.RetVal,len(B.RetVal)-charindex('=',B.RetVal+'=')-1)
From YourTable A
Cross Apply (
Select RetSeq = Row_Number() over (Order By (Select null))
,RetVal = LTrim(RTrim(B.i.value('(./text())[1]', 'varchar(max)')))
From (Select x = Cast('<x>' + replace((Select replace(A.Parameters,'|','§§Split§§') as [*] For XML Path('')),'§§Split§§','</x><x>')+'</x>' as xml).query('.')) as A
Cross Apply x.nodes('x') AS B(i)
) B
-- YOUR OPTIONAL WHERE STATEMENT HERE For example: Where A.ID=1
<强>返回强>
答案 1 :(得分:0)
我只能看到你选择了一个列,导致该列中有大量文本。您可以将其导出为excel并使用“Text to Column”功能,并使用PIPE |作为分隔符,EQUAL =符号。这将导致每个|的单独列和=签名。