I have an XML file that I pass to a stored procedure.
I also have a table. The table shows the columns VehicleReg | XML | Processeddate
My XML looks like this:
<vehicles>
<vehicle>
<vehiclereg>AB12CBE</vehiclereg>
<anotherprop>BLAH</anotherprop>
</vehicle>
<vehicle>
<vehiclereg>AB12CBE</vehiclereg>
<anotherprop>BLAH</anotherprop>
</vehicle>
</vehicles>
What I need to do is read the xml and insert the carlereg line and the full xml line of the vehicle in each line (dateprocessed - getdate (), so no problem).
I worked on something like below, but no luck:
DECLARE @XmlData XML
Set @XmlData = EXAMPLE XML
SELECT T.Vehicle.value('(vehiclereg)[1]', 'NVARCHAR(10)') AS vehiclereg,
T.Vehicle.value('.', 'NVARCHAR(MAX)'),
GETDATE()
FROM @XmlData.nodes('Vehicles/Vehicle') AS T(Vehicle)
I was wondering if anyone could point me in the right direction?
Hi
source
share