您现在的位置是:网站首页> 编程资料编程资料
SQL Server把某个字段的数据用一条语句转换成字符串_MsSql_
2023-05-26
341人已围观
简介 SQL Server把某个字段的数据用一条语句转换成字符串_MsSql_
例如数据 列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根据分区表名查找所在的文件及文件组实现脚本_MsSql_
- SQL Server查询数据库中表使用空间信息实现脚本_MsSql_
- SQL Server中使用Trigger监控存储过程更改脚本实例_MsSql_
- SQL Server中通配符的使用示例_MsSql_
- SQL语句实现查询当前数据库IO等待状况_MsSql_
- SQL语句实现查询并自动创建Missing Index_MsSql_
- SQL语句实现查询Index使用状况_MsSql_
- SQL语句实现查询SQL Server内存使用状况_MsSql_
- SQL语句实现查询SQL Server服务器名称和IP地址_MsSql_
- 查询SQL Server Index上次Rebuild时间的方法_MsSql_
