摘要:
在sql server 中实现分解字符串的方法的脚本如下:create Function [dbo].[fn_SplitStr]( @SourceSql VARCHAR(max), -- 字符串 @StrSeprate VARCHAR(10) -- 用于分解的字符)RETURNS @temp TABLE(F1 VARCHAR(100))AS BEGIN DECLARE @i INT SET @SourceSql = RTRIM(LTRIM(@SourceSql)) SET @i=CHARINDEX(@StrSeprate,@SourceSql) ... 阅读全文
摘要:
type valuea 0b 1c 2d 3a 2a 3d 1b 0c 0得到结果:type valuea 0,2,3b 1,0c 2,0d 3,1select [type], stuff((select ','+ltrim(value) from tb where [type]=[type] for xml path('')),1,1,'') [value]from tbgroup by [type]; 阅读全文