更改sql xml auto的视图/样式

时间:2011-05-24 10:22:39

标签: sql xml cursor

我有下面的代码(继续我之前的问题SQL How to list Columns in a Table as a Cursor Statement

select 
    (select * from
        (select Narrative 
         from OfficeClientLedger
         where ptMatter=$Matter$ and ptTrans = 4) 
     as Disbursments for xml auto)

返回

<OFFICECLIENTLEDGER NARRATIVE="M0604/20 Cwm Taff NHS Trust Medical Records (C)"/><OFFICECLIENTLEDGER NARRATIVE="M0604/210 Dr Purby Medeical Records (C)"/><OFFICECLIENTLEDGER NARRATIVE="M0604.20 Orchid Cellmark tld Fee"/><OFFICECLIENTLEDGER NARRATIVE="M0604/20 Parsons Dowd Psychological Ltd Assessment Fees"/><OFFICECLIENTLEDGER NARRATIVE="M0604/20 Dr R  Oretti Drug testing"/><OFFICECLIENTLEDGER NARRATIVE="M0604/20 Correction of MIssposting CQ 013524"/><OFFICECLIENTLEDGER NARRATIVE="M0604/20 Helen Blackler Assessment Fees (P) "/> 

但是,我需要它给我一个列表,如

  

M0604 / 20 Cwm Taff NHS Trust Medical   记录(C)

     

M0604 / 210 Purby Medeical Records博士   (C)

     

M0604.20 Orchid Cellmark tld费

     

M0604 / 20 Parsons Dowd

     

M0604 / 20 R Oretti博士药物测试

     

M0604 / 20 MIsposting CQ的更正   013524

     

M0604 / 20 Helen Blackler评估   费用(P)

任何想法?感谢

2 个答案:

答案 0 :(得分:1)

select
(select cast(Narrative as varchar(max))
from OfficeClientLedger
where ptMatter=$Matter$ and ptTrans = 4
as Disbursments for xml path(''), true)

答案 1 :(得分:0)

您可以使用XSL样式表更改从SQL Server检索的XML的格式。

http://sqlxml.org/faqs.aspx?faq=99