Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ftsoft
Starting Member
22 Posts |
Posted - 2009-10-29 : 14:22:46
|
In the code below, I get 2 rows generated, but the second row has the same value as the first (105 instead of 115). Can anyone help with this.xml as follows<E02>...<E02_06>105</E02_06><E02_06>115</E02_06></E02>Stored Proc is as followsINSERT INTO E02_06(fk_E01, E02_06)SELECT @ParentID, E02_06FROM OPENXML(@index, 'E02',2)WITH (fk_E01 INT, E02_06 INT) |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-10-29 : 15:21:03
|
can you please show us the full xml? how are you getting @parentidDECLARE @docHandle intDECLARE @xmlDocument nvarchar(max) -- or xml typedeclare @ParentID intdeclare @index intSET @xmlDocument = N'<E02><E02_06>105</E02_06><E02_06>115</E02_06></E02>'EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocumentSELECT @ParentID, E02_06FROM OPENXML(@docHandle, 'E02',2)WITH (fk_E01 INT, E02_06 INT)<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
ftsoft
Starting Member
22 Posts |
Posted - 2009-10-29 : 21:21:16
|
Posting further documentation. We were stuck with the rather lame xml hierarchy.the relevant xml- <DATA_RECORD>- <E01> <E01_01>2009128</E01_01> <E01_02>FTSoft</E01_02> <E01_03>Tipp City IRS</E01_03> <E01_04>V01.1</E01_04> </E01>- <E02> <E02_01>55-027</E02_01> <E02_04>30</E02_04> <E02_05>75</E02_05> <E02_06>105</E02_06> <E02_06>115</E02_06> <E02_07>150</E02_07> <E02_08>225</E02_08> <E02_09>290</E02_09> <E02_10>360</E02_10> <E02_12>303</E02_12> <E02_20>390</E02_20> </E02>snipthe SPALTER PROCEDURE [dbo].[OpenXMLTest]( @newRun Varchar(8000), @id VARCHAR(10)) ASBEGINDECLARE @index intDECLARE @ParentID intSELECT @ParentID=pk_E01 FROM E01 Where E01_01=@id EXEC sp_xml_preparedocument @index OUTPUT, @newRunUPDATE E02SET E02_01=xmlTable.E02_01, E02_04=xmlTable.E02_04, E02_05=xmlTable.E02_05, E02_12=xmlTable.E02_12, E02_20=xmlTable.E02_20FROM OPENXML(@index, 'DATA_RECORD/E02',2)WITH (E02_01 VARCHAR(7), E02_04 INT, E02_05 INT, E02_12 VARCHAR(15), E02_20 INT)xmlTableWHERE E02.pk_E01 = @ParentIDINSERT INTO E02_06(fk_E01,E02_06)SELECT @ParentID,E02_06FROM OPENXML(@index, 'DATA_RECORD/E02',2)WITH (E02_06 INT)ENDThanks |
 |
|
|
|
|
|
|