FOR XML PATH
来源:互联网 发布:国内阿里云搭建ss教程 编辑:程序博客网 时间:2024/05/22 03:12
I would like to share the approach of ‘FOR XML PATH’.
We can use ‘FOR XML PATH’ to concatenate rows, if you have the database 'AdventureWorks' in SQLServer, you can run the following statement, for example:
- Concatenate rows
SELECT CAT.Name AS[Category],
STUFF((SELECT',' + SUB.Name AS [text()]
FROM Production.ProductSubcategory SUB
WHERE SUB.ProductCategoryID = CAT.ProductCategoryID
FORXML PATH('')), 1, 1, '') -- This is done to remove the first character (,) fromthe result
AS [Sub Categories]
FROM Production.ProductCategory CAT
- Get the xml data from a table
SELECT ProductCategoryKey AS '@CategoryKey',
EnglishProductCategoryName AS '@CategoryName'
FROM AdventureWorksDW2012.dbo.DimProductCategory
FOR XML PATH('Category'), ROOT('Categorys')
- FOR XML PATH
- for xml path(string)
- for xml path('')
- FOR XML PATH
- sqlserver for xml path
- sql For XML Path
- for xml path
- sql for xml path
- SQL FOR XML PATH
- for xml path
- for xml path
- For XML Path
- mssql for xml path
- for xml path
- sql for xml path
- FOR XML PATH
- For XML PATH
- SQLSERVER FOR XML PATH
- Jamendo学习笔记之:播放流程
- MCI 错误 提示系统为装入驱动
- maven2——设置镜像篇
- DWR3.0+Spring2.5实现Comet服务器到浏览器的消息推送 .
- ios中构建多视图小结
- FOR XML PATH
- JAVA学习(一)从今天开始学习JAVA
- Tomcat 部署web应用方法总结
- org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout waiting for connection异常解决方案
- java解析获取Excel中的数据--同时兼容2003及2007
- 正斜杠(/)反斜杠(\)简单区别
- Formatter使用
- 非技术性 MySQL慢查询指南
- PocketSphinx语音识别系统声学模型的训练与使用