0

I have an xml script in a customer table. Below structure is the Structure I need it in table for

<pricer xmlns="http://www.Card.com/xxxx/xxxx">
  <service>
    <response>
      <businessObjectModel>
        <Id>0</Id>
        <Card xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Card">
          <ID>1</ID>
          <Inc>0.0</Inc>
          <value>0.0</value>
          <Tvalue1>0.0</Tvalue1>
        </Card>
      </businessObjectModel>

I need like below table:

enter image description here

1
  • 3
    Which RDBMS do you use? Commented Oct 6, 2015 at 10:10

1 Answer 1

1

If you want to iterate Card's you can do it like this:

   DECLARE @XML XML
SET @XML = '
<pricer xmlns:xsi="http://www.Card.com/xxxx/xxxx">
  <service>
    <response>
      <businessObjectModel>
        <Id>0</Id>
        <Card xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Card">
          <ID>1</ID>
          <Inc>0.0</Inc>
          <value>0.0</value>
          <Tvalue1>0.0</Tvalue1>
        </Card>
      </businessObjectModel>
      <businessObjectModel>
        <Id>1</Id>
        <Card xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Card">
          <ID>1</ID>
          <Inc>2.0</Inc>
          <value>1.0</value>
          <Tvalue1>2.0</Tvalue1>
        </Card>
      </businessObjectModel>
      </response></service></pricer>'

SELECT   
Tbl.Col.value('ID[1]', 'int'),
Tbl.Col.value('Inc[1]', 'decimal'),
Tbl.Col.value('value[1]', 'decimal'),
Tbl.Col.value('Tvalue1[1]', 'decimal')
FROM   @XML.nodes('pricer/service/response/businessObjectModel/Card') Tbl(Col)
GO
Sign up to request clarification or add additional context in comments.

1 Comment

i can not system will generate in above format only .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.