SQL has no array data type. You can simulate an array by using substring functions. Here is another example, using substrings and WHILE loops. Modify as need for your application. I coded this for fixed length strings with leading spaces. I also haven't accounted for the string containing all z's.
create table #tmp (StrData char(10), recid int identity)
set nocount on
insert #tmp values('aaaaaabzzz')
insert #tmp values(' zzzz')
insert #tmp values(' abz0z')
insert #tmp values('aaaaaaazzy')
insert #tmp values('wzzzzzzzzw')
insert #tmp values('wzzzzzzzzz')
insert #tmp values('aaaaaabz9z')
go
declare
@str char(10),
@cn tinyint, @cs char(1), @done tinyint,
@rn tinyint, @mn tinyint
Select @rn=1, @mn=max(recid) From #tmp
While @rn<=@mn
Begin
Select
@cn=10, @done=0,
@str=StrData From #tmp Where RecID=@rn
Print @str
While @done=0 And @cn>0
Begin
Select @cs=substring(@str,@cn,1)
If (@cs>='a' And @cs<='y') Or (@cs>='0' And @cs<='8')
Begin
Select @cs=char(ascii(@cs)+1)
Select @str=Stuff(@str,@cn,1,@cs), @done=1
End
Else
If @cs='9'
Begin
Select @cs='a'
Select @str=Stuff(@str,@cn,1,@cs), @done=1
End
Else
If @cs='z'
Begin
Select @cs='0'
Select @str=Stuff(@str,@cn,1,@cs), @cn=@cn-1
End
Else
If @cs=' '
Begin
Select @cs='a'
Select @str=Stuff(@str,@cn,1,@cs), @done=1
End
End
Select @rn=@rn+1
Print @str
Print ''
End
go
Drop table #tmp
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.