I have a bunch of xml files that I need to load in. They all look like this<Root> <MuniData> <Muni_ID>8</Muni_ID> <BuildingPermit>t-343</BuildingPermit> <WorkType>XML</WorkType> <Address>134 xml</Address> <ParcelID> 4343</ParcelID> <PermitLink>http://testxml</PermitLink> <RequiresExcavation>1</RequiresExcavation> </MuniData> <MuniData> <Muni_ID>8</Muni_ID> <BuildingPermit>t-344</BuildingPermit> <WorkType>XML</WorkType> <Address>1345 xml</Address> <ParcelID> 4349</ParcelID> <PermitLink>http://testxml</PermitLink> <RequiresExcavation>1</RequiresExcavation> </MuniData></Root>
I need to be able to load them into a table that is structured as suchCREATE TABLE [dbo].[Initial_DataLoad]( [ID] [bigint] IDENTITY(-999999999,1) NOT NULL, [Muni_ID] [int] NOT NULL, [BuildingPermit] [varchar](100) NULL, [WorkType] [varchar](100) NULL, [Address] [varchar](500) NULL, [ParcelID] [varchar](50) NULL, [PermitLink] [varchar](max) NULL, [RequiresExcavation] [bit] NULL, [SentToProcessing] [bit] NOT NULL, [ProcessedByNorfield] [bit] NOT NULL, [SentToHistory] [bit] NOT NULL, [TicketNumber] [varchar](12) NULL, [TicketDate] [datetime] NULL) ON [PRIMARY]
The files are stored locally on the server. I just need a way to read and parse the xml into a / the table. I have managed to read the whole xml blob into 1 column, but then am having trouble parsing that column out to all the various values. Ideally, I would like for it to just insert into the table directly via parsing and inserting. Thank you for the help.