2016-07-22 62 views

回答

0

使用數字table所有號碼..

;With cte 
as 
(
select top 20 number 
from numbers 
order by number 
) 
Insert into yourtable 
select top 1* from cte c1 where not exists(select 1 from yourtable t2 where t1.number=t2.id) 

您還可以使用加入..

Insert into yourtable 
select top 1 number 
from 
numbers n 
join 
yourtable t 
on t.id<>n.number 
and n<=20 
+0

Thnak you爲了回答,我會檢查它,我會回來 – user6615498