日期:2014-05-18 浏览次数:20604 次
--> 测试数据: @T --创建个自定义函数 create function fn_insertsign(@str varchar(100)) returns varchar(100) as begin declare @i INT,@j int select @i=ceiling(len(@str)/5.00), @j=0 declare @s varchar(100) set @s='' while (@j<@i) begin set @s=@s+substring(@str,@j*5+1,5)+',' set @j=@j+1 end return @s end --测试数据 declare @T table (字段1 int,字段2 varchar(100)) insert into @T select 1,'fkdsaewewjkeljelwjelwkejewlkew' union all select 2,'ddsadsadadsadsadqwqwqewqeqwe' --更新数据 update @T set 字段2=dbo.fn_insertsign(字段2) select * from @T /* 字段1 字段2 ----------- ---------------------------------------- 1 fkdsa,ewewj,kelje,lwjel,wkeje,wlkew, 2 ddsad,sadad,sadsa,dqwqw,qewqe,qwe, */