SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 create a procedure to read XML and get data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nitin05.sharma
Starting Member

India
18 Posts

Posted - 04/26/2012 :  03:37:44  Show Profile  Reply with Quote
i have convert datatable to XML
and find a string of XML type
<NewDataSet>
<Table1>
<TableName>T_NCO_LNK_AST_AC_MISSN_VARNT</TableName>
<FieldName>EFF_DT</FieldName>
<FieldValue>123</FieldValue>
</Table1>
</NewDataSet>

i want to create a procedure read this XML string and insert into temp table
thanks in advance
please help me
its urgent

nitin05.sharma
Starting Member

India
18 Posts

Posted - 04/26/2012 :  04:45:54  Show Profile  Reply with Quote
<NewDataSet>
<Table1>
<TableName>T_NCO_LNK_AST_AC_MISSN_VARNT</TableName>
<FieldName>EFF_DT</FieldName>
<FieldValue>123</FieldValue>
</Table1>
<Table1>
<TableName>T_OBJ</TableName>
<FieldName>OBJ_RID</FieldName>
<FieldValue>1</FieldValue>
</Table1>
</NewDataSet>

XML string may this
Go to Top of Page

stepson
Yak Posting Veteran

Romania
85 Posts

Posted - 04/27/2012 :  01:54:03  Show Profile  Reply with Quote
declare @xml as xml

set @xml='<NewDataSet>
<Table1>
<TableName>T_NCO_LNK_AST_AC_MISSN_VARNT</TableName>
<FieldName>EFF_DT</FieldName>
<FieldValue>123</FieldValue>
</Table1>
<Table1>
<TableName>T_OBJ</TableName>
<FieldName>OBJ_RID</FieldName>
<FieldValue>1</FieldValue>
</Table1>
</NewDataSet>'


select
q.t.value('TableName[1]','varchar(50)') as tableName,
q.t.value('FieldName[1]','varchar(50)') as FieldName,
q.t.value('FieldValue[1]','varchar(50)') as FieldValue

from @xml.nodes('/NewDataSet/Table1') as q(t)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000