Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, Below extract from XML file:
HTML


<CreditApplication ID="1776065">
<creditapplicationdetails>
<p4lmargin>4.3
<lendermargin>79.3
<p4lmarketing>0
<lendermarketing>0


Equivalent Select Query to read the XML:

SELECT
/*APPLICATION ID*/
CreditApplicationID = ca.value('@ID','INT')
/*APPLICATION DETAILS*/
, P4LMargin = ca.value('(CreditApplicationDetails/P4LMargin/text())[1]','DECIMAL(16,3)')
, LenderMargin = ca.value('(CreditApplicationDetails/LenderMargin/text())[1]','DECIMAL(16,3)')
, P4LMarketing = ca.value('(CreditApplicationDetails/P4LMarketing/text())[1]','BIT')
, LenderMarketing = ca.value('(CreditApplicationDetails/LenderMarketing/text())[1]','BIT')

FROM
AppFileXML tXML
CROSS APPLY tXML.AppFileXMLContent.nodes('MIData/CreditApplication') AS CredAppl(ca)

Now the below two flages :

<p4lmarketing>0
<lendermarketing>0

are changed to :

<Marketing type="CloseBrothersLimited">1
<Marketing type="CloseBrothersPlc">0

What will be the equivalent SQL query for the same? Please help, Thanks in Advance



Thanks & Regards,
Aditya Agarwal

What I have tried:

I am new to XML any help would be highly appreciated
Posted
Updated 22-May-18 4:49am
v2

1 solution

Replace:
CreditApplicationDetails/P4LMargin/text()
with:
CreditApplicationDetails/Marketing[@type="CloseBrothersLimited"]/text()

I'm sure you can work out what to do for the other element. 🙂
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900