字符串自增1怎么写 M-001自增到M-999我需要一个select写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select 'M'+right('00'+RTRIM(number+1),3)from master..spt_values where number<999and type='p'/*-------M001M002M003M004M005M006M007M008M009M010M011M012M013...M999 select 'M-'+right('00'+RTRIM(number+1),3)from master..spt_values where number<999and type='p' 看来我说错了我是需要M-001可以自增到M-990如果M-001就M-002M-002到M-003不是一下全部生存999 --这样?试试update tb set col='M-'+right('00'+rtrim(convert(int,replace(col,'M-',''))+1),3) --select的话这样select col='M-'+right('00'+rtrim(convert(int,replace(col,'M-',''))+1),3) from tb select 'M-'+max(cast(right(col,len(col)-2) as int)) as colfrom tb 7楼有问题!select 'M-'+right(1001+max(cast(right(col,len(col)-2) as int)),3) as colfrom tb select 'M-'+right(1001+isnull(max(cast(right(col,len(col)-2) as int)),0),3) as colfrom tb 请问运程复制数据的错误 背份和还原问题,谢谢大家,来的都有分 sqlserver2000和visualstio.net2.0有冲突么? SQLSERVER中的CASE WHEN,在ACCESS中应该用什么? 问一条SQL语句 SQL日期函数 敬请高手帮帮忙??? 触发器如何才能忽略错误,不产生回滚 请问在win NT 4.0 workstation中能安装oracl 8.0.5吗? VB数据库高手来挑战一下这个问题 UPDATE 问题 请教一个SQL语句写法
from master..spt_values where number<999
and type='p'/*
-------
M001
M002
M003
M004
M005
M006
M007
M008
M009
M010
M011
M012
M013
...
M999
select 'M-'+right('00'+RTRIM(number+1),3)
from master..spt_values where number<999
and type='p'
我是需要M-001可以自增到M-990
如果M-001就M-002
M-002到M-003不是一下全部生存999
--这样?试试
update tb set col='M-'+right('00'+rtrim(convert(int,replace(col,'M-',''))+1),3)
--select的话这样
select col='M-'+right('00'+rtrim(convert(int,replace(col,'M-',''))+1),3) from tb
select 'M-'+max(cast(right(col,len(col)-2) as int)) as col
from tb
select 'M-'+right(1001+max(cast(right(col,len(col)-2) as int)),3) as col
from tb
select 'M-'+right(1001+isnull(max(cast(right(col,len(col)-2) as int)),0),3) as col
from tb