I am trying to separate a string that consists of integers by comma. For example, @string = '22222222222222223333333333333333', I want to convert it to @string ='2222222222222222,33333333333333'
For every 16 digits, put a comma delimited string. Here is my code, but doesn;t work correctly. Please correct me. thanks
declare @string nvarchar(max) declare @length int declare @string2 nvarchar(max) declare @i int set @string = '22222222222222223333333333333333' --set @length = 2 set @i = 1 while @length = len(@string)/16 begin select @string2 = substring (@string,@i,16)+',' set @i = @i+16 end select @string2