SQL Server把某个字段的数据用一条语句转换成字符串
2018-10-12 14:10
435 查看
例如数据 列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把某个字段的数据用一条语句转换成字符串
- 一条语句将一个字段数据换转成一个字符串
- sql语句查询某字段中包含指定字符串的数据列表,完全匹配字段中逗号中间的字符串数据
- 读取一条记录数据里边所有字段 MySQLi语句
- 将泛型集合类(List<T>)转换成DataTable,返回的DataTable所有列的数据类型为string型,且列顺序与字符串提供的字段顺序一致
- sql server中用convert函数将日期型字段转换成字符串
- SQL SERVER 用sql语句将一列数据拼接成一个字符串
- SQL SERVER 用sql语句将一列数据拼接成一个字符串
- java多线程,将oracle中数据导入到sql到文件(包括大字段转换成字符串)
- 修改sql server 数据库字段报错:将截断字符串或二进制数据
- sql server 查询表信息,字段,数据类型的sql语句
- ORACLE判断哪儿儿写数据字符串类型字段不能转换成日期格式
- 一条SQL语句插入大量数据 和查看某个表的字段是否有重复值
- 一条语句删除表中某字段重复的数据
- mysql数据库语句 的case when用法,以及数据替换,字符串拼接,时间格式转换的用法
- SQL SERVER字符串前加N,什么含义?,SQL语句里nchar类型的字段我不想加N,怎么办?
- sql server中用convert函数将日期型字段转换成字符串
- 在sql server中,如何使用一条语句实现将表1中的数据复制到表2中
- 把SQL Server数据表的内容转换为相应的INSERT语句