摘要: 在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) ... 阅读全文
posted @ 2012-04-27 18:26 小锋神 阅读(2644) 评论(0) 推荐(0)
摘要: 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]; 阅读全文
posted @ 2012-04-27 15:12 小锋神 阅读(403) 评论(0) 推荐(1)
摘要: 阅读全文
posted @ 2012-04-27 13:37 小锋神 阅读(280) 评论(0) 推荐(0)