1
我有以下xml,我想將它作爲表插入到sql server中。 問題是我不知道如何在沒有獨特屬性或元素的情況下手工創建xml結構。我已經閱讀了很多教程,但似乎沒有任何工作。將xml插入到沒有唯一屬性的sql server中
<Table>
<Row>
<Cell><Data ss:Type="Number">157882</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">441944.8990</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">211469.0100</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">1838.8610</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">1.9955</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">2.2767</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">0.2252</Data></Cell>
<Cell><Data ss:Type="Number">0</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">63.5774</Data></Cell>
<Cell><Data ss:Type="Number">115</Data></Cell>
<Cell><Data ss:Type="Number">15</Data></Cell>
<Cell><Data ss:Type="Number">50</Data></Cell>
<Cell><Data ss:Type="Number">72</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number">76922</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">441944.8990</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">211469.0100</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">1838.8610</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">1.9955</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">2.2767</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">0.2252</Data></Cell>
<Cell><Data ss:Type="Number">0</Data></Cell>
<Cell ss:StyleID="ce1"><Data ss:Type="Number">63.5774</Data></Cell>
<Cell><Data ss:Type="Number">115</Data></Cell>
<Cell><Data ss:Type="Number">15</Data></Cell>
<Cell><Data ss:Type="Number">72</Data></Cell>
<Cell><Data ss:Type="Number">50</Data></Cell>
</Row> </Table>
我在SQL電流源:
INSERT INTO report (var1,var2,var3....var13)
SELECT X.Cell.query('Data').value('.', 'VARCHAR(30)'),
X.Cell.query('Data').value('.', 'VARCHAR(30)'),
X.Cell.query('Data').value('.', 'VARCHAR(30)')
.
.
. .
.
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'C:\xml_import.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('Table/Row') AS X(Cell);
你有什麼想法?