SQL Server ->> 生成Numbers辅助表
时间:2021-07-01 10:21:17
帮助过:2人阅读
object_id(
‘MyDB.dbo.Numbers‘)
is not null
drop table MyDB.dbo.Numbers
go
use [MyDB]
go
create table dbo.Numbers(ID
INT NOT NULL)
go
create unique clustered index ix_uniq_clst_numbers_id
on dbo.Numbers(id)
go
with t
as (
select row_number()
over (
order by col1)
as rowno
from (
select top 1000000 1 as col1
from sys.syscolumns a, sys.syscolumns b, sys.syscolumns c) t
)
insert into dbo.Numbers
select rowno
from t
order by rowno
SQL Server ->> 生成Numbers辅助表
标签: