将表转化成XML的格式返回
EG:
SELECT TOP 5 md.ID,md.DepartName,md.OrganID,md.LastEditDate FROM mdDepartment md
1 总经办 40 2009-06-24 16:21:52.450
2 广告商务部 03 2009-06-24 16:22:02.827
3 品牌商务部 02 2009-06-24 16:22:08.280
4 客户发展部 04 2009-06-24 16:22:13.530
5 增值三部 NULL 2009-11-05 14:20:31.750
SELECT TOP 5 md.ID,md.DepartName,md.OrganID,md.LastEditDate FROM mdDepartment md
FOR XML PATH,ROOT('root')
<root>
<row>
<ID>1</ID>
<DepartName>总经办</DepartName>
<OrganID>40</OrganID>
<LastEditDate>2009-06-24T16:21:52.450</LastEditDate>
</row>
<row>
<ID>2</ID>
<DepartName>广告商务部</DepartName>
<OrganID>03</OrganID>
<LastEditDate>2009-06-24T16:22:02.827</LastEditDate>
</row>
<row>
<ID>3</ID>
<DepartName>品牌商务部</DepartName>
<OrganID>02</OrganID>
<LastEditDate>2009-06-24T16:22:08.280</LastEditDate>
</row>
<row>
<ID>4</ID>
<DepartName>客户发展部</DepartName>
<OrganID>04</OrganID>
<LastEditDate>2009-06-24T16:22:13.530</LastEditDate>
</row>
<row>
<ID>5</ID>
<DepartName>增值三部</DepartName>
<LastEditDate>2009-11-05T14:20:31.750</LastEditDate>
</row>
</root>
--------------------------------- --------------------------------- --------------------------------- ---------------------------------
SELECT * FROM oa.dbo.bswProductType
FOR XML PATH('BswProductTypeEntity')
1 0 01 体重管理类 1 sa 2012-01-06 00:00:00.000 D01865D9-45AF-43B4-AE3D-47BE42EB4947
2 0 02 体形管理类 2 sa 2012-01-06 00:00:00.000 4CE2DAA8-0E5C-486D-920A-652CA3D16F67
3 0 03 辅助类 3 sa 2012-01-06 00:00:00.000 3737D69D-9B5B-4BE2-9C40-E07056F145B1
<BswProductTypeEntity>
<ID>1</ID>
<ParentID>0</ParentID>
<OrganID>01</OrganID>
<TypeName>体重管理类</TypeName>
<OrderBy>1</OrderBy>
<LastEditBy>sa</LastEditBy>
<LastEditDate>2012-01-06T00:00:00</LastEditDate>
<msrepl_tran_version>D01865D9-45AF-43B4-AE3D-47BE42EB4947</msrepl_tran_version>
</BswProductTypeEntity>
<BswProductTypeEntity>
<ID>2</ID>
<ParentID>0</ParentID>
<OrganID>02</OrganID>
<TypeName>体形管理类</TypeName>
<OrderBy>2</OrderBy>
<LastEditBy>sa</LastEditBy>
<LastEditDate>2012-01-06T00:00:00</LastEditDate>
<msrepl_tran_version>4CE2DAA8-0E5C-486D-920A-652CA3D16F67</msrepl_tran_version>
</BswProductTypeEntity>
<BswProductTypeEntity>
<ID>3</ID>
<ParentID>0</ParentID>
<OrganID>03</OrganID>
<TypeName>辅助类</TypeName>
<OrderBy>3</OrderBy>
<LastEditBy>sa</LastEditBy>
<LastEditDate>2012-01-06T00:00:00</LastEditDate>
<msrepl_tran_version>3737D69D-9B5B-4BE2-9C40-E07056F145B1</msrepl_tran_version>
</BswProductTypeEntity>