/*
Hi,
Below is a very simple scenario where you can parse the xml in sql server (2005 and above) and put data into a table.
You can use the sql server xml data type for the purpose.
*/
Declare @xmlData Xml
Set @xmlData = '<data>
<row Id="1">AAA</row>
<row Id="2">BBB</row>
<row Id="3">CCC</row>
</data>'
-- In the table below we will put data from the xml.
Declare @Data Table (Id Int, Name Varchar(100))
--
Select r.c.value('@Id[1]', 'int'),
r.c.value('.[1]', 'varchar(100)')
From @xmlData.nodes ('data/row') r(c)
-- Note your stored procedure should look like the one below
Create Procedure [Stored Proc Name]
@xmlData Xml
Begin
-- Code
End
-- For more stuff on xml data type please visit http://msdn.microsoft.com/en-us/library/ms190798
FarhanK
Contributor
2603 Points
349 Posts
Re: how to solve this problem ?
Jun 01, 2012 05:19 AM|LINK
/* Hi, Below is a very simple scenario where you can parse the xml in sql server (2005 and above) and put data into a table. You can use the sql server xml data type for the purpose. */ Declare @xmlData Xml Set @xmlData = '<data> <row Id="1">AAA</row> <row Id="2">BBB</row> <row Id="3">CCC</row> </data>' -- In the table below we will put data from the xml. Declare @Data Table (Id Int, Name Varchar(100)) -- Select r.c.value('@Id[1]', 'int'), r.c.value('.[1]', 'varchar(100)') From @xmlData.nodes ('data/row') r(c) -- Note your stored procedure should look like the one below Create Procedure [Stored Proc Name] @xmlData Xml Begin -- Code End -- For more stuff on xml data type please visit http://msdn.microsoft.com/en-us/library/ms190798Regards,
Farhan Uddin Khan
Breeze Technologies