set nocount on;
if object_id('dbo.nums') is not null
drop table dbo.nums
go
create table dbo.nums
(
n int not null primary key
);
declare @max as int,@rc as int;
set @max=100000
set @rc=1;
insert into Nums values(1);
while @rc*2<=@max
begin
insert into dbo.Nums select n+@rc from dbo.nums;
set @rc=@rc*2;
end;
insert into dbo.Nums select n+@rc from dbo.Nums where n+@rc<=@max;
数字辅助表
最新推荐文章于 2021-04-11 17:34:07 发布