SQL怎么提取字段中XML内容,并插入到 ଠ另外一张表

2025-04-25 17:03:26
推荐回答(1个)
回答1:

-- 数据库用户名 UAGReport  表名student 已创建
use UAGReport
go  
DECLARE @doc varchar(1000)  
DECLARE @idoc int 
SET @doc='  
            
          6  
          sun  
          male  
           24  
           
  
          
'  
  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