So far I have managed to get to
SELECT
h.c.value('@supplierref[1]' , 'VARCHAR(6)') AS supplierref,
h.c.value('@suppliername[1]' , 'VARCHAR(50)') AS suppliername
FROM ( SELECT XMLTEXT AS Xmlreport FROM @WORKINGXML) d
CROSS APPLY Xmlreport.nodes('//Remittance') AS a(c)
OUTER APPLY a.c.nodes('supplier') h(c)
OUTER APPLY a.c.nodes('faxnumber') s(c)
which gives me the supplierref and supplier name. what I want to do is also get the xml remittance for that supplier so I can add supplierref, supppliername and xml to a table
ie
supplierref = 'ABCDE' , SupplierNAme = 'SUPPLIER 1' and xml to equel (tags removed to post )
So my question to you is, where is this xml file? Or do you mean this data is currently saved in an xml datatype column? and do you want to dump the result our to an xml file or an xml result using TSQL?
the xml file is stored in a crm multiline field. I would like it dumped as an xml result as it is part of a stored procedure returning results back to a crm workflow
yes but what is the source of this data, is it sql server database table? and you want it to be dumped to disk? the crm must be getting it from somewhere to display it in a UI multiline field
I receive a text file from a customer with remittance advices. This gets converted to an xml file and stored within CRM ( sql database ) . When the file is uploaded into CRM, the CRM system will fire a custom workflow ( the part I'm working on ), that hopefully will call a stored procedure and create the individual supplier remittances xml data that will be returned to the workflow for processing. I have used xml files before with stored procedures and normal just return a table from a Select command
ie in this instance from a stored procedure id like to return
supplierref suppliername, xml data
ABCDE SUPPLIER 1 xml data ( as shown above )
if that's not possible, the to be able to create an xml file for each supplier's remittance to disc will work just as well as I can read that back into the workflow.
select
c.value('supplier[1]/@supplierref', 'varchar(6)') AS supplierref,
c.value('supplier[1]/@suppliername[1]' , 'VARCHAR(50)') AS suppliername,
c.query('.') as RemittanceXML
from
@WORKINGXML.nodes('//Remittance') T(c)