My XML was:
set @xml=N'
<root>
<attribute col1="attr1" col2="varchar(200)" col3="A"/>
<attribute col1="attr2" col2="varchar(200)" col3="A"/>
<attribute col1="attr3" col2="varchar(200)" col3="B"/>
<attribute col1="attr4" col2="varchar(200)" col3="C"/>
</root>'
I converted the XML into Base
table in SQL Server:
COL1 COL2 COL3
-----------------------------
attr1 varchar(200) A
attr2 varchar(200) A
attr3 varchar(200) B
attr4 varchar(200) C
I want to create tables like
create table A
(
attr1 varchar(200),
attr2 varchar(200)
)
and similarly for B and C in COL3
2条答案
按热度按时间l2osamch1#
You can insert values into a new table based on a select query.
But you will have to do this for every distinct value of
COL3
.rkttyhzu2#
you can use python to do it,
mapping contains the map of which column you want to extract