SQL怎么提取字段中XML内容,并插入到 另外一张表
1个回答
展开全部
-- 数据库用户名 UAGReport 表名student 已创建
use UAGReport
go
DECLARE @doc varchar(1000)
DECLARE @idoc int
SET @doc='<ROOT>
<student>
<id>6</id>
<name>sun</name>
<sex>male</sex>
<age>24</age>
</student>
</ROOT>'
exec sp_xml_preparedocument @idoc output,@doc
select * from openxml(@idoc,'/ROOT/student',2)
with(id int,name varchar(40),sex varchar(20), age int)
insert student
select * from openxml(@idoc,'/ROOT/student',2)
with student
exec sp_xml_removedocument @idoc
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询