-- 資料庫使用者名稱 UAGReport 表名student 已建立use UAGReportgo 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
-- 資料庫使用者名稱 UAGReport 表名student 已建立use UAGReportgo 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