日期:2014-05-17 浏览次数:20921 次
with T as
(select count(0) As NUM from tab where name like '重庆%')
insert into tab (name) values('重庆' + case T.NUM when 0 then '' else cast(T.NUm as varchar(10)) end)
declare @string varchar(500)set @string = '宁155ML2123232'declare @len intset @len = len(@string)declare @outstr varchar(500)set @outstr = ''declare @tempstr varchar(1)while (@len>0)begin set @tempstr = substring(@string,@len,1) if (@tempstr >= '0' and @tempstr <= '9') begin set @outstr = @tempstr + @outstr end else begin break end set @len = @len - 1endselect @outstr
declare @string varchar(500)
set @string = '宁155ML2123232'
declare @len int
set @len = len(@string)
declare @outstr varchar(500)
set @outstr = ''
declare @tempstr varchar(1)
while (@len>0)
begin
set @tempstr = substring(@string,@len,1)
if (@tempstr >= '0' and @tempstr <= '9')
begin
set @outstr = @tempstr + @outstr
end
else
begin
break
end
set @len = @len - 1endselect
@outstr
with T as
(select isnull(max(cast(replace(name,'重庆','') as int),0) As maxNo from tab where name like '重庆%')
insert into tab (name) values('重庆' + case T.maxNo when 0 then '' else cast((T.maxNo +1)as varchar(10)) end)