How to insert multiple record using xml in sql server 2005+
How to insert the multiple record using the xml into sql server, please check the following example.
DECLARE @idoc int
DECLARE @doc varchar(max)
SET @doc =’
<ROOT>
TransId=”1″ Add=”false” Edit=”true” Delete=”true” View=”true” Block=”false”>
</ROOT>’
–Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
– Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT * Into #TempTable
FROM OPENXML
(@idoc, ‘/ROOT/Trans’,1)
WITH (
TransId varchar(10),
[Add] bit,
Edit bit,
[Delete] bit,
[View] bit,
Block bit )
Select * From #TempTable
– drop temp table
drop table #TempTable
–
happy coding
Advertisement
1 Comment »
Leave a Reply
-
Archives
- April 2011 (1)
- May 2010 (1)
- April 2010 (1)
- February 2010 (3)
- January 2010 (5)
- December 2009 (6)
- November 2009 (13)
- October 2009 (10)
- September 2009 (6)
- August 2009 (7)
- July 2009 (7)
- June 2009 (3)
-
Categories
-
RSS
Entries RSS
Comments RSS
thanx …..