日期:2014-05-17 浏览次数:20697 次
DECLARE @i TABLE (date datetime,NO varchar(20))
INSERT INTO @i(date,NO)
SELECT '2012-01-01','201201001'
UNION ALL
SELECT '2013-01-01','201301003'
UNION ALL
SELECT '2014-01-01',null
select convert(VARCHAR(6),[date],112)+
case when right([no],3) is NULL OR right([no],3)='' then '001'
else right('00'+convert(varchar,convert(int,right([no],3))+1),3)
end as plusno
from @i
/*
201201002
201301004
201401001*/