Home > Database > Mysql Tutorial > SQL Server中将多行的内容显示在一列中

SQL Server中将多行的内容显示在一列中

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:20:09
Original
1140 people have browsed it

SQL SERVER 2005支持XML格式数据,这个方法就是利用XML来进行转换。

SQL SERVER 2005支持XML格式数据,这个方法就是利用XML来进行转换。

STUFF(REPLACE(REPLACE((SELECT COL1 FROM [TABLE] N FOR XML AUTO ), '', ''), 1, 1, '')

在查询语句后加FOR XML AUTO可以得到查询结果的xml类型格式为:

通过replace函数替换掉xml中结果以外的数据。

通过stuff函数将第一个节点替换的,去掉。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template