在拥有此 xml 数据时:
<machine>ZSK40-2</machine>
<date>2013/08/28</date>
<hour>12:37</hour>
<CollectedData>
<variable>
<Name>PRODUCT</Name>
<Value>FILLER 580</Value>
</variable>
<variable>
<Name>LOT_NUMBER</Name>
<Value>CG 00063 0</Value>
</variable>
<variable>
<Name>SHIFT_SUPERVISOR</Name>
<Value> covaliu l</Value>
</variable>
<variable>
<Name>KGH_ALL_SET</Name>
<Value>90</Value>
</variable>
<variable>
<Name>KGH_ALL_REAL</Name>
<Value>133.183883666992</Value>
</variable>
<variable>
<Name>KGH_F1_SET</Name>
<Value>90</Value>
</variable>
<variable>
<Name>KGH_F1_REAL</Name>
<Value>133.183883666992</Value>
</variable>
<variable>
<Name>K_F1</Name>
<Value>33</Value>
</variable>
<variable>
<Name>SCREW_RPM_SET</Name>
<Value>400</Value>
</variable>
<variable>
<Name>SCREW_RPM_REAL</Name>
<Value>399.452606201172</Value>
</variable>
<variable>
<Name>TORQUE</Name>
<Value>19.6692142486572</Value>
</variable>
<variable>
<Name>CURRENT</Name>
<Value>71.0029983520508</Value>
</variable>
<variable>
<Name>KW_KG</Name>
<Value>0.0553370267152786</Value>
</variable>
<variable>
<Name>KW</Name>
<Value>7.36999988555908</Value>
</variable>
<variable>
<Name>MELT_PRESSURE</Name>
<Value>0</Value>
</variable>
<variable>
<Name>MELT_TEMPERATURE</Name>
<Value>140</Value>
</variable>
<variable>
<Name>PV1</Name>
<Value>141</Value>
</variable>
<variable>
<Name>SP1</Name>
<Value>140</Value>
</variable>
<variable>
<Name>PV2</Name>
<Value>160</Value>
</variable>
<variable>
<Name>SP2</Name>
<Value>160</Value>
</variable>
<variable>
<Name>PV3</Name>
<Value>160</Value>
</variable>
<variable>
<Name>SP3</Name>
<Value>160</Value>
</variable>
<variable>
<Name>PV4</Name>
<Value>160</Value>
</variable>
<variable>
<Name>SP4</Name>
<Value>160</Value>
</variable>
<variable>
<Name>PV5</Name>
<Value>160</Value>
</variable>
<variable>
<Name>SP5</Name>
<Value>160</Value>
</variable>
<variable>
<Name>PV6</Name>
<Value>150</Value>
</variable>
<variable>
<Name>SP6</Name>
<Value>150</Value>
</variable>
<variable>
<Name>PV7</Name>
<Value>150</Value>
</variable>
<variable>
<Name>SP7</Name>
<Value>150</Value>
</variable>
<variable>
<Name>PV8</Name>
<Value>154</Value>
</variable>
<variable>
<Name>SP8</Name>
<Value>150</Value>
</variable>
<variable>
<Name>PV9</Name>
<Value>150</Value>
</variable>
<variable>
<Name>SP9</Name>
<Value>150</Value>
</variable>
<variable>
<Name>PV10</Name>
<Value>160</Value>
</variable>
<variable>
<Name>SP10</Name>
<Value>160</Value>
</variable>
<variable>
<Name>PV11</Name>
<Value>180</Value>
</variable>
<variable>
<Name>SP11</Name>
<Value>180</Value>
</variable>
</CollectedData>
并使用此脚本:
CREATE TABLE #ZSK70(
Name varchar(25) ,
Value varchar(30) );
INSERT INTO #ZSK70 (Name, Value)
SELECT X.variable.query('Name').value('.', 'varchar(25)'),
X.variable.query('Value').value('.', 'varchar(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'C:\20130828_1237_ZSK40-2.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('CollectedData/variable') AS X(variable);
select * from #ZSK70
drop table #ZSK70
我从 xml 中获取一些数据。我怎样才能在日期时间行中获得机器和日期+时间。在此先感谢您的帮助!会留意这里。