Phil Parkin (10/23/2016)
Super_Grover (10/23/2016)
Phil Parkin (10/23/2016)
Is doc_number unique?It is unique AFAIKS but it's not an unbroken sequnece. In other words: it does not stay in sync with the row numbers (doc_numbers are missing so to say)
OK, then you could easily create a temp table with an identity column and insert all of the doc_numbers into that. Then join from the temp table on doc_number and you have your numbering scheme.
Untested code to get you started
Create table #doc_numbers(RowNum int identity(1,1) primary key clustered, doc_number nvarchar(20) not null)
insert #doc_numbers (doc_number)
select doc_number
from tbl
Thank you Phil. But wouldn't that cost me even more diskspace by creating and filling another table?
I think I'm more looking for a way do the INSERT INTO SELECT FROM in small batches.