question about import xml to sql table# Database - 数据库
i*c
1 楼
以下是从xml插入表的sql:
CREATE TABLE emps (ID int, EmpName varchar(30))
GO
DECLARE @hDoc int
DECLARE @cDoc varchar(8000)
SET @cDOC = 'ASmith BOBNewName> '
EXEC sp_xml_preparedocument @hDoc OUTPUT, @cDoc
INSERT INTO emps
SELECT *
FROM OPENXML(@hDOC, '/ROOT/NewName', 3)
WITH
(
ID int '@ID',
NewName varchar(30) '.'
)
EXEC sp_xml_removedocument @hdoc
go
SELECT * FROM emps
go
请教如何改xml内容为文件,试了以下sql报错:
CREATE TABLE emps
CREATE TABLE emps (ID int, EmpName varchar(30))
GO
DECLARE @hDoc int
DECLARE @cDoc varchar(8000)
SET @cDOC = '
EXEC sp_xml_preparedocument @hDoc OUTPUT, @cDoc
INSERT INTO emps
SELECT *
FROM OPENXML(@hDOC, '/ROOT/NewName', 3)
WITH
(
ID int '@ID',
NewName varchar(30) '.'
)
EXEC sp_xml_removedocument @hdoc
go
SELECT * FROM emps
go
请教如何改xml内容为文件,试了以下sql报错:
CREATE TABLE emps