Hi,
I have 10k xml files in a folder.
The sampe file may be somehting like this
<policy>
<SubPolicy>
<Customer1>
<id>1000</id>
<name>Peter</name>
<term>12months</term>
<vehicletype>car</vehicletype>
<city>Charlotte</city>
<state>NC</state>
</customer1>
<Customer2>
<id>2000</id>
<name>John</name>
<term>12months</term>
<vehicletype>Bike</vehicletype>
<city>Charlotte</city>
<state>NC</state>
</customer2>
</SubPOlicy>
</POlicy>
I want to store the values in the xml files in to differnet tables in a database. Can you please help me on this..
Example, in the customer_maintable, I manually insert the records like this
create table dbo.customer_Maintable
(ID int,
[Type] varchar(20)
)
insert into dbo.customer_Maintable values ('1','name')
insert into dbo.customer_Maintable values ('2','Term')
insert into dbo.customer_Maintable values ('3','VehicleType')
insert into dbo.customer_Maintable values ('4','City')
insert into dbo.customer_Maintable values ('5','State')
then, in the dbo.customer_Transactiontable, the corresponding values should populate like the below output.
create table dbo.customer_Transactiontable
(
customer_TransactionID int identity (1,1),
CustomerID int,
CustomerMainTable_ID int,
Value varchar(20)
)
insert into dbo.customer_Transactiontable values (1000,1,'Peter')
insert into dbo.customer_Transactiontable values (1000,2,'12months')
insert into dbo.customer_Transactiontable values (1000,3,'car')
insert into dbo.customer_Transactiontable values (1000,4,'Charlotte')
insert into dbo.customer_Transactiontable values (1000,5,'NC')
insert into dbo.customer_Transactiontable values (2000,1,'John')
insert into dbo.customer_Transactiontable values (2000,2,'12months')
insert into dbo.customer_Transactiontable values (3000,3,'Bike')
insert into dbo.customer_Transactiontable values (4000,4,'Charlotte')
insert into dbo.customer_Transactiontable values (5000,5,'NC')
Can you please help me on this? In the future, if another tag/xpath comes, example <salary>5000</salary>, then , I should
do a insert an entry in the main table, like the below
insert into dbo.customer_Maintable values ('6','Salary') , then the salary should be correctly loaded in dbo.customer_Transactiontable table, using a
SSIS package or from a stored procedure.
Can yo please help me on this?