例如数据 列Name
代码如下:
name
a
b
c
d
最后的结果
代码如下:
a*b*c*d*
declare @test table( namevarchar(10))
insert into @testvalues('a'),('b'),('c'),('d');
select distinct
(select cast(name asvarchar(2))+'*'from @test for xml path(''))as name from @test
输出结果:
代码如下:
(4 row(s) affected)
name
--------------------------------------------------
a*b*c*d*
(1 row(s) affected)
您可能感兴趣的文章:
- MySQL的一些常用的SQL语句整理
- MySQL基本操作语句小结
- MySQL存储过程中实现执行动态SQL语句的方法
- 整理MySql常用查询语句(23种)
- 非常好用的sql语句(日常整理)