--create proc test
--as
declare @str varchar(100)='123456789'
declare @str1 varchar(100)
declare @count int=1
declare @c int =len(@str)
declare @str2 varchar=''
select @str1= SUBSTRING(@str,4,1)+SUBSTRING(@str,2,1)+SUBSTRING(@str,6,1)
select @str1= REVERSE(@str1)
declare @i int=1
-- select LEN(@str1)
while(@count<=@c)
begin
if(@count%2=0)
begin
--select 'abc'
select @str = STUFF(@str,@count,1,substring(@str1,@i,1))
set @i=@i+1
end
set @count=@count+1
-- select @count
end
select @str
--select @str2=CHARINDEX('6',@str1,1)
--select CHARINDEX('6',@str1,1)
--select STUFF(@str,2,0,'a')
No comments:
Post a Comment