Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 472.3k

How to translate xml data to sql query?

Jun 2 2023 1:46 PM

Hi Team

I need help with my ER diagram, must first need to translate xml data to sql query then insert this data to ER diagram so could have unique primary key and foreign key.

 

CREATE TABLE OrderHeader (
    OrderNumber VARCHAR(10),
    OrderType VARCHAR(20),
    OrderStatus VARCHAR(20),
    CustomerName VARCHAR(50),
    CreateDate DATETIME
);

CREATE TABLE OrderLine (
    OrderNumber VARCHAR(10),
    LineNumber INT,
    ProductCode VARCHAR(20),
    ProductType VARCHAR(20),
    CostPrice DECIMAL(10, 2),
    SalesPrice DECIMAL(10, 2),
    Quantity INT
);


// xml data
. <SalesOrder>
<OrderHeader>
<OrderNumber>SO625144</OrderNumber>
<OrderType>Normal</ OrderType>
<OrderStatus>New</ OrderStatus>
<CustomerName>KFC</ CustomerName>
<CreateDate>2018-03-08 13:52:21</ CreateDate>
</OrderHeader>
<OrderLine>
<LineNumber>1</ LineNumber>
<ProductCode>GSX837420</ ProductCode>
<ProductType>Parts</ ProductType>
<CostPrice>13.54</ CostPrice>
<SalesPrice>84.49</ SalesPrice>
<Quantity>10</ Quantity>
</ OrderLine>
<OrderLine>
<LineNumber>2</ LineNumber>
<ProductCode>AVF697420</ ProductCode>
<ProductType>Apparel</ ProductType>
<CostPrice>19.34</ CostPrice>
<SalesPrice>105.99</ SalesPrice>
<Quantity>25</ Quantity>
</ OrderLine>
</SalesOrder>
<SalesOrder>
<OrderHeader>
<OrderNumber>SO625145</OrderNumber>
<OrderType>Normal</ OrderType>
<OrderStatus>New</ OrderStatus>

<CustomerName>Nandos</ CustomerName>
<CreateDate>2018-03-09 08:56:21</ CreateDate>
</OrderHeader>
<OrderLine>
<LineNumber>1</ LineNumber>

// ER diagram


Answers (1)