What is the best way to create and populate a numbers table?

后端 未结 11 2533
悲&欢浪女
悲&欢浪女 2020-11-21 13:28

I\'ve seen many different ways to create and populate a numbers table. However, what is the best way to create and populate one? With \"best\" being defined from most to l

11条回答
  •  青春惊慌失措
    2020-11-21 14:03

    i use this which is fast as hell:

    insert into Numbers(N)
    select top 1000000 row_number() over(order by t1.number) as N
    from   master..spt_values t1 
           cross join master..spt_values t2
    

提交回复
热议问题