萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> sql server教程 >> sqlserver快速插入大批量連續數字

sqlserver快速插入大批量連續數字

有時候處於測試要求,需要在數據庫裡快速插入大批量連續數字,下面是實現語句。

with
l0 as (select 1 as C union all select 1 as C),--2-1
l1 as (select 1 as C from l0 as A,l0 as B),--2-2
l2 as (select 1 as C from l1 as A,l1 as B),--2-4
l3 as (select 1 as C from l2 as A,l2 as B),--2-16
l4 as (select 1 as C from l3 as A,l3 as B),--2-256
l5 as (select 1 as C from l4 as A,l4 as B)--2-256^2
select ROW_NUMBER () over (order by C) as n into Nums from l5

關鍵詞:批量  插入  數字  快速  連續 

copyright © 萬盛學電腦網 all rights reserved