22,209
社区成员
发帖
与我相关
我的任务
分享
;with t
as
(select 1 as num
union all
select num+1 from t
where num+1<=999)
select right(1000+num,3)
from t option(maxrecursion 0)
select top 999 right('00000'+rtrim(row_number() over(order by o.name)),3)
from sys.objects o,sys.columns c
select right('00'+convert(nvarchar(4),number),3) as num
from Master.dbo.spt_values where type='p'
and number between 1 and 999
declare @i int
set @i=1
while @i<999
begin
print right('000'+ltrim(@i),3);
set @i=@i+1
end
select right(1000+number,3) as code
from master..spt_values
where type = 'p' and number between 1 and 999
select top 999 identity(int,1,1) as id into #t
from sys.objects o,sys.columns c
select right(1000+id,3) as num from #t
drop table #t