Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I have a problem while inserting this xml file in sql server , it is inserting but the blank rows is inserting so Please help for this


SQL
CREATE TABLE #WorkingTable (Data XML)
INSERT INTO #WorkingTable
SELECT *
FROM   OPENROWSET(BULK 'D:\xml\Employee.xml',SINGLE_BLOB) AS data

/* Import the users records from the working table */
SQL
DECLARE  @XML  AS XML
SELECT @XML = Data
FROM   #WorkingTable
--drop table #WorkingTable
--select * from #WorkingTable
declare @hDoc  AS INT
EXEC sp_xml_preparedocument @hDoc OUTPUT ,@XML
INSERT INTO LeadStatusRepository
SELECT * FROM   OPENXML (@hDoc,'/NewDataSet/Table',1) with Employee

/* Clean up and empty out our temporary table */
SQL
EXEC sp_xml_removedocument @hDoc
DROP TABLE #WorkingTable
Posted
Updated 11-Apr-12 3:42am
v2
Comments
RDBurmon 5-Jun-12 1:15am    
Tell me How can we help without knowing data in Employee.xml file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900