Wednesday, March 4, 2009

Pulling records from SQL data as tree structure (multi-level) xml

If you want to create multi level(root ->child record-child record)xml message from SQL for biztalk inbound, then you have to use for xml explicit keyword for t-sql and the example is given below

SELECT
Tag
,Parent
,'Table' AS [Table!1!sEntity!element]
,sTable_GUID AS [Table!1!sTable_GUID!element]

,sPhone_no AS [Tablephone!2!sPhone_no!element] ,sPhoneType_cd AS [Tablephone!2!sPhoneType_cd!element]
,sAddressType_cd AS [Tableaddress!3!sAddressType_cd!element]
,sAddress_nm AS [Tableaddress!3!szAddress_nm!element
FROM
tbTableDetails
FOR XML EXPLICIT, BINARY BASE64

No comments:

 test