Not logged in - Login

Creating new rows with sequential numbers

One example of how to create a select statement that outputs a series of rows with sequential numbers.

-- declare a variable to hold the number of sequential numbers we want to return
declare @n int
set @n = 3000

select top (@n) 
   NewNumber = ROW_NUMBER() OVER (ORDER BY a.[object_ID] ASC)
from sys.all_columns a
cross apply sys.all_columns b -- do the cross apply to ensure that we have enough rows

Other examples here: What is the best way to create and populate a numbers table?]