A5下载 - 努力做内容最丰富最安全的下载站!

A5站长下载站

当前位置:A5下载 > 安全相关 > SQL Server把某个字段的数据用一条语句转换成字符串

SQL Server把某个字段的数据用一条语句转换成字符串

时间:2015-07-11 11:37作者:zhao人气:43

例如数据 列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)

标签SQL,Server,某个,字段,数据,一条,语句,换成,字

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

公众号