Wednesday, September 24, 2008

Sample Source code for Bulk insert using OPENXML?

DECLARE @studentXML XML
DECLARE @xmlHandle INT
SET @studentXML = '



'
EXEC SP_XML_PREPAREDOCUMENT @xmlHandle OUTPUT, @studentXML
SELECT studentName
,studentID
INTO #student
FROM OPENXML( @xmlHandle, '/students/student', 1 )
WITH
(
studentName VARCHAR(10) '@name',
studentID VARCHAR(3) '@id'
)
EXEC SP_XML_REMOVEDOCUMENT @xmlHandle
SELECT * FROM #student
DROP TABLE #student

Please look at this link..
http://www.informit.com/articles/article.aspx?p=102307&seqNum=6

This is also good link to refer, bulk insert and update
http://sqlxml.org/faqs.aspx?faq=100

No comments: