列值转换为逗号分隔字符串
程序员文章站
2022-03-20 19:24:00
将数据表的某一列值,转换为逗号分隔字符串: 先准备一些数据: DECLARE @t AS TABLE([Datas] NVARCHAR(40)) INSERT INTO @t ([Datas]) VALUES(N'DF'),(N'W4F'),(N'EYY'),(N'ER'),(N'GFF'),(N' ......
将数据表的某一列值,转换为逗号分隔字符串:
先准备一些数据:
declare @t as table([datas] nvarchar(40)) insert into @t ([datas]) values(n'df'),(n'w4f'),(n'eyy'),(n'er'),(n'gff'),(n'a445') select [datas] from @t order by [datas]
一二句sql代码的事:
declare @commadelimitedstring nvarchar(max) select @commadelimitedstring = isnull(@commadelimitedstring + ',', '') + [datas] from @t order by [datas] select @commadelimitedstring
上一篇: PHP中上传文件打印错误,错误类型
下一篇: @RestController注解