http://bbs.51cto.com/thread-433820-1-1.htmldeclare @code varchar(50)
select top 1 @code = UserCode from Info_User where charindex('071030',UserCode)>0 order by id desc
select @code
set @code=substring(@code,10,len(@code))
select @code
set @code='111'
set @code = @code +1
set @code = right('000'+convert(varchar,@code),3)
select @code
select top 1 @code = UserCode from Info_User where charindex('071030',UserCode)>0 order by id desc
select @code
set @code=substring(@code,10,len(@code))
select @code
set @code='111'
set @code = @code +1
set @code = right('000'+convert(varchar,@code),3)
select @code