Adhikar Patil

Adhikar Patil

  • NA
  • 481
  • 128.9k

How to Insert Data From XML File to Sql Table

Oct 3 2018 8:12 AM
Hello,
      I Have two tables as Listed below :
 
1) EmployeeMaster
 
CREATE TABLE [dbo].[EmployeeMaster](
[EmpId] [int] NOT NULL Primary Key,
[EmpName] [nvarchar](50) NULL
)
 
 2) EmployeeRole
 
CREATE TABLE [dbo].[EmployeeRole](
[RoleId] [int] NOT NULL,
[RoleName] [varchar](50) NULL,
[EmpId] [int] NULL
 
Also I am Having MasterData.xml also 
 
<?xml version="1.0" encoding="utf-8" ?>
<Data>
 
<EmployeeMaster>
<EmpId>1</EmpId>
<EmpName>Adhikar</EmpName>
</EmployeeMaster>
 
<EmployeeMaster>
<EmpId>2</EmpId>
<EmpName>Amit</EmpName>
</EmployeeMaster>
 
<EmployeeRole>
<RoleId>1</RoleId> 
<RoleName>Admin</RoleName> 
<EmpId>1</EmpId>
</EmployeeRole>
 
<EmployeeRole>
<RoleId>2</RoleId>
<RoleName>Employee</RoleName>
<EmpId>3</EmpId> 
</EmployeeRole>
 
</Data> 
 
So Now i want to insert this xml file data into  EmployeeMaster and EmployeeRole table in MVC. So please give me the solution.
 

Answers (2)