Here is how u can upload an XML directly to SQL Table
DECLARE @INTPOINTER AS INT
DECLARE @XML AS XML
SET @XML = '<UpdateRentalData>
<verhuurderField>
<fiscaalNumberField>100000009</fiscaalNumberField>
<huurobjectField>
<kalehuurField>444444</kalehuurField>
<postcodeField>2342ff</postcodeField>
<recordCodeField>105</recordCodeField>
</huurobjectField>
<recordCodeField>002</recordCodeField>
</verhuurderField>
</UpdateRentalData>'
DECLARE @TEMP_TABLE TABLE (
fiscaalNumberField NVARCHAR(50),
kalehuurField NVARCHAR(50),
postcodeField NVARCHAR(50),
recordCodeField NVARCHAR(50)
)
EXEC sp_xml_preparedocument @INTPOINTER OUTPUT, @XML
Insert into @TEMP_TABLE
Select * from OpenXml(@INTPOINTER,'/UpdateRentalData/verhuurderField/huurobjectField',2)
With (
fiscaalNumberField NVARCHAR(50) '../fiscaalNumberField',
kalehuurField NVARCHAR(50) ,
postcodeField NVARCHAR(50),
recordCodeField NVARCHAR(50) '../recordCodeField'
)
exec sp_xml_removedocument @INTPOINTER
SELECT * FROM @TEMP_TABLE
DECLARE @XML AS XML
SET @XML = '<UpdateRentalData>
<verhuurderField>
<fiscaalNumberField>100000009</fiscaalNumberField>
<huurobjectField>
<kalehuurField>444444</kalehuurField>
<postcodeField>2342ff</postcodeField>
<recordCodeField>105</recordCodeField>
</huurobjectField>
<recordCodeField>002</recordCodeField>
</verhuurderField>
</UpdateRentalData>'
DECLARE @TEMP_TABLE TABLE (
fiscaalNumberField NVARCHAR(50),
kalehuurField NVARCHAR(50),
postcodeField NVARCHAR(50),
recordCodeField NVARCHAR(50)
)
EXEC sp_xml_preparedocument @INTPOINTER OUTPUT, @XML
Insert into @TEMP_TABLE
Select * from OpenXml(@INTPOINTER,'/UpdateRentalData/verhuurderField/huurobjectField',2)
With (
fiscaalNumberField NVARCHAR(50) '../fiscaalNumberField',
kalehuurField NVARCHAR(50) ,
postcodeField NVARCHAR(50),
recordCodeField NVARCHAR(50) '../recordCodeField'
)
exec sp_xml_removedocument @INTPOINTER
SELECT * FROM @TEMP_TABLE
No comments:
Post a Comment